📄 perftest2.jc
字号:
/*
* perftest2.jc
*
* A simple performance test. Count repeatedly from 0 to 1.000.000 and take average time.
*/
// Import Typelibs
import stdlib;
// number of iterations the script will do
const long kNumIterations = 100;
// time to sleep between iterations (to avoid heat)
const long kSleepTimeMillisec = 200;
/*
* function main
*/
function string main()
{
long i;
long j;
long startTime;
long duration;
float durationF = 0;
float iters = 1;
string message;
stdlib::Print("A simple performance test. Count repeatedly from 0 to 1.000.000 and take average time.\n");
for( j = 0; j < kNumIterations; j++ )
{
startTime = stdlib::GetTicks();
for( i = 0; i < 1000000; i++ )
/*Empty statement*/;
duration = stdlib::GetTicks() - startTime;
durationF += duration;
stdlib::Printf("Iteration #%g: Time = %d ms (Average time = %g ms)\n", {iters, duration, durationF / iters} );
stdlib::Sleep(kSleepTimeMillisec); // wait a little... be nice to your CPU ;)
iters++;
}
return "Done.";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -