?? bufferbench1.java
字號:
package mpi.pt2pt;
import mpi.*;
import mpjbuf.*;
import java.util.Arrays;
public class BufferBench1 {
public BufferBench1() {
}
public BufferBench1(String args[]) throws Exception{
int REPEAT = 1000 , k=0;
long time[] = new long[REPEAT] ;
long cum_time;
long minimum = 0L;
long start = 0L;
long end = 0L;
long maxMemory=0L, freeMemory=0L, totalMemory=0L;
mpjbuf.RawBuffer buffer ;
int i=0,j=0;
Runtime rt = Runtime.getRuntime() ;
System.out.println("# size allocation_time used_mem "+
"total_memory max_memory");
for(int u=0 ; u<100000 ; u++) {
for(j=128 ; j<=16*1024*1024 ; j*=2) {
buffer = BufferFactory.create(j) ;
BufferFactory.destroy( buffer );
}
}
//try { Thread.currentThread().sleep(500); } catch(Exception e) {}
for(j=128 ; j<=16*1024*1024 ; j*=2) {
for(int q=0 ; q<10 ; q++) {
cum_time = 0L;
for(k=0 ; k<REPEAT ; k++) {
start = System.nanoTime();
buffer = BufferFactory.create(j) ;
end = System.nanoTime();
time[k] = end-start ;
//maxMemory = rt.maxMemory();
//totalMemory = rt.totalMemory();
//freeMemory = rt.freeMemory();
//memory[k] = rt.totalMemory() - rt.freeMemory() ;
BufferFactory.destroy( buffer );
}
for(k=0 ; k<REPEAT ; k++) {
cum_time += time[k] ;
//cum_mem += memory[k] ;
//print time here ...
}
if(q == 0) {
minimum = cum_time;
//min_mem = cum_mem ;
} else {
if(cum_time < minimum) {
minimum = cum_time;
//min_mem = cum_mem ;
}
}
}
System.out.println(j+" "+
(minimum)/(1000.0*REPEAT)+" ");
//(min_mem)/(1024*1024)+" ");
//totalMemory/(1024*1024)+" "+
//maxMemory/(1024*1024));
}
}
public static void main(String args[]) throws Exception{
BufferBench1 test = new BufferBench1(args);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -