private void init() { _scale = 1.0; _translate = new Vector3(0.0,0.0,0.0); _azimuth = 40.0; _elevation = 25.0; _projection = Projection.PERSPECTIVE; _ndraw = 0; _stopwatch = new Stopwatch(); _stopwatch.start(); }
static double benchList(double maxtime, int n, ListMaker lm) { Stopwatch sw = new Stopwatch(); sw.start(); int niter; for (niter=0; sw.time()<maxtime; ++niter) lm.makeList(n); sw.stop(); return (double)n*(double)niter/sw.time()*1.0e-6; }
private static void benchFloat( ArrayFile af, int n) throws IOException { float[] a = randfloat(n); float[] b = zerofloat(n); int nio; Stopwatch sw = new Stopwatch(); sw.start(); for (nio=0; sw.time()<5.0; ++nio) { af.seek(0); af.writeFloats(a); af.seek(0); af.readFloats(b); } sw.stop(); for (int i=0; i<n; ++i) if (a[i]!=b[i]) throw new RuntimeException(" float: i/o failure"); double time = sw.time(); double rate = 2.0*4.0e-6*nio*n/time; System.out.println(" float: rate="+rate+" MB/s"); }
Stopwatch sw = new Stopwatch(); int nh = 60; // like a trace header int na = 1000; // like trace samples
private static void benchDouble( ArrayFile af, int n) throws IOException { double[] a = randdouble(n); double[] b = zerodouble(n); int nio; Stopwatch sw = new Stopwatch(); sw.start(); for (nio=0; sw.time()<5.0; ++nio) { af.seek(0); af.writeDoubles(a); af.seek(0); af.readDoubles(b); } sw.stop(); for (int i=0; i<n; ++i) if (a[i]!=b[i]) throw new RuntimeException("double: i/o failure"); double time = sw.time(); double rate = 2.0*8.0e-6*nio*n/time; System.out.println("double: rate="+rate+" MB/s"); } }
public void benchAddNode() { java.util.Random random = new java.util.Random(); for (int itest=0; itest<3; ++itest) { for (int nnode=1000; nnode<=64000; nnode*=2) { Stopwatch sw = new Stopwatch(); sw.restart(); TriMesh tm = new TriMesh(); for (int inode=0; inode<nnode; ++inode) { float x = random.nextFloat(); float y = random.nextFloat(); TriMesh.Node node = new TriMesh.Node(x,y); tm.addNode(node); } sw.stop(); System.out.println( "Added "+nnode+" nodes to make "+tm.countTris() + " tris in "+sw.time()+" seconds."); tm.validate(); } try { System.out.println("Sleeping"); Thread.sleep(5000,0); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
for (int itest=0; itest<16; ++itest) { for (int nnode=1000; nnode<=64000; nnode*=2) { Stopwatch sw = new Stopwatch(); sw.reset(); sw.start();
private static double time(int nfft) { double maxtime = 2.0; FftComplex fft = new FftComplex(nfft); float[] cx = crandfloat(nfft); int count; Stopwatch sw = new Stopwatch(); sw.start(); for (count=0; sw.time()<maxtime; ++count) { fft.complexToComplex(-1,cx,cx); fft.complexToComplex( 1,cx,cx); fft.scale(nfft,cx); } sw.stop(); double time = sw.time()/(float)count; return time; } }
double rate,sum; int n; Stopwatch sw = new Stopwatch(); for (int niter=0; niter<5; ++niter) { sw.restart();
private static void bench3() { int n1 = 501; int n2 = 502; int n3 = 503; Random r = new Random(314159); float[][][] x = randfloat(r,n1,n2,n3); float[][][] y = randfloat(r,n1,n2,n3); RecursiveGaussianFilter rf = new RecursiveGaussianFilter(3.0f); int niter; double maxtime = 5.0; double nsample = (double)n1*(double)n2*(double)n3; Stopwatch sw = new Stopwatch(); for (int itest=0; itest<3; ++itest) { sw.restart(); for (niter=0; sw.time()<maxtime; ++niter) rf.apply000(x,y); sw.stop(); float sum = sum(y); int rate = (int)(1.0e-6*niter*nsample/sw.time()); System.out.println("rate = "+rate+" sum = "+sum); } } }
double maxtime = 5.0; double nsample = (double)n1*(double)n2; Stopwatch sw = new Stopwatch(); for (int itest=0; itest<3; ++itest) { sw.restart();
private static void testMethods(TestFunction tf, float[][] fx) { float[] f = fx[0], x1 = fx[1], x2 = fx[2], x3 = fx[3]; System.out.println(); //SibsonInterpolator3.Method[] methods = {HL,WS,BS}; SibsonInterpolator3.Method[] methods = {HL}; for (SibsonInterpolator3.Method method:methods) { SibsonInterpolator3 si = new SibsonInterpolator3(method,f,x1,x2,x3); si.setNullValue(1.0f); si.setBounds(SX,SX,SX); si.setGradientPower(1.0); double tmin = Double.MAX_VALUE; float[][][] g = null; for (int iter=0; iter<3; ++iter) { Stopwatch sw = new Stopwatch(); sw.start(); g = si.interpolate(SX,SX,SX); sw.stop(); tmin = min(tmin,sw.time()); } System.out.println("method="+method+" time="+tmin); System.out.println("min="+min(g)+" max="+max(g)); plot(method,g); } } private static void dump(float[] f, float[] x1, float[] x2, float[] x3) {
double maxtime = 5.0; double nsample = (double)n1*(double)n2*(double)n3; Stopwatch sw = new Stopwatch(); for (int itest=0; itest<3; ++itest) { sw.restart();
private static void benchMatrixMultiply() { int m = 1001; int n = 1002; System.out.println("Matrix multiply for m="+m+" n="+n); float[][] a = randfloat(n,m); float[][] b = randfloat(m,n); float[][] cs = zerofloat(m,m); float[][] cp = zerofloat(m,m); int niter,rate; double maxtime = 5.0; double mflop = 2.0e-6*m*m*n; Stopwatch sw = new Stopwatch(); for (int ntest=0; ntest<3; ++ntest) { sw.restart(); for (niter=0; sw.time()<maxtime; ++niter) { matrixMultiplySerial(a,b,cs); } sw.stop(); rate = (int)((niter*mflop)/sw.time()); System.out.println("S: rate = "+rate+" mflops"); sw.restart(); for (niter=0; sw.time()<maxtime; ++niter) { matrixMultiplyParallel(a,b,cp); } sw.stop(); rate = (int)((niter*mflop)/sw.time()); System.out.println("P: rate = "+rate+" mflops"); } } private static void matrixMultiplySerial(
public void display(GLAutoDrawable drawable) { Stopwatch s = new Stopwatch(); int nloop;
Stopwatch s = new Stopwatch(); int nloop,rate; double maxtime = 2.0;
public static void bench() { double maxtime = 2.0; Stopwatch sw = new Stopwatch(); for (int n=10; n<10000; n*=10) { System.out.println("n="+n);
public static void bench() { Stopwatch sw = new Stopwatch(); int n = 1000001; // odd, so median equals one array element double maxtime = 2.0;
Stopwatch sw = new Stopwatch(); int nplane; int niter = 100;
public void test() { double sleepTime = 0.1; // time to sleep in seconds double smallTime = 0.01; // time errors less than this are ignored Stopwatch sw = new Stopwatch();