Skip to content

Commit

Permalink
add overall summary report by run
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jan 6, 2025
1 parent f02710c commit 7a8d2c4
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
30 changes: 30 additions & 0 deletions custom/benchmark/benchmarkUtils.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,36 @@ component {
return false;
}

function reportRuns( srcRuns ) localmode=true {

var runs = duplicate( srcRuns );
arraySort(
runs,
function (e1, e2){
if (e1.totalDuration lt e2.totalDuration) return -1;
else if (e1.totalDuration gt e2.totalDuration) return 1;
return 0;
}
); // fastest to slowest

var hdr = [ "Version", "Java", "Time" ];
var div = [ "---", "---", "---:" ];
_logger( "" );
_logger( "|" & arrayToList( hdr, "|" ) & "|" );
_logger( "|" & arrayToList( div, "|" ) & "|" );

var row = [];
loop array=runs item="local.run" {
ArrayAppend( row, run.version );
ArrayAppend( row, run.java );
arrayAppend( row, numberFormat( run.totalDuration ) );
_logger( "|" & arrayToList( row, "|" ) & "|" );
row = [];
}

_logger( "" );
}

function reportTests( runs,
sectionTitle="Suite / Spec",
sectionKey="suiteName",
Expand Down
51 changes: 49 additions & 2 deletions custom/benchmark/index.cfm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<cfscript>
never_runs = int( ( server.system.environment.BENCHMARK_CYCLES ?: 0.5 ) * 1000);
never_runs = int( ( server.system.environment.BENCHMARK_CYCLES ?: 25 ) * 1000);
once_runs = int( ( server.system.environment.BENCHMARK_ONCE_CYCLES ?: 0.5) * 1000)
warmup_runs = 1000; // ensure level 4 compilation
setting requesttimeout=never_runs+once_runs;
Expand Down Expand Up @@ -78,6 +78,7 @@
systemOutput( getCpuUsage() );
sleep( 5000 ); // initial time to settle
run_startTime = getTickCount();
loop list="once,never" item="inspect" {
systemOutput("", true);
configImport( {"inspectTemplate": inspect }, "server", "admin" );
Expand Down Expand Up @@ -168,6 +169,8 @@
}
}
results.run.totalDuration = getTickCount() - run_startTime;
_logger( message="" );
_logger( message="-------test run complete------" );
Expand Down Expand Up @@ -206,9 +209,53 @@
systemOutput( "--------- no #logFile# [#log#]", true );
}
}
_logger( message="-------finished dumping logs------" );
do_heap_dump = server.system.environment.BENCHMARK_HEAPDUMP ?: false;
if ( do_heap_dump ){
_logger( "" );
_logger( message="-------heap dump------" );
logs = "";
_log = "";
results = "";
result = "";
arr = "";
for (v in variables){
if (!isCustomFunction(variables[v]))
systemOutput(v & ": " & len(variables[v]), true);
}
application name="bench";
applicationStop();
admin
action="purgeExpiredSessions"
type="server"
password="admin";
_logger( message="-------trigger GC------" );
createObject( "java", "java.lang.System" ).gc();
_memStatGC = reportMem( "", _memBefore.usage, "before", "HEAP" );
for ( r in _memStatGC.report )
_logger( r );
_logger( "" );
dir = getDirectoryFromPath( getCurrentTemplatePath() ) & "heapdumps/";
if ( !directoryExists( dir ) )
directoryCreate( dir );
dumpFile = dir & "heapdump-#lsDateTimeFormat(now(),'yyyy-mm-dd-HH-nn-ss')#.hprof";
systemOutput( "Dumping heap to #dumpFile#", true );
admin
type="server"
password="admin"
action="heapDump"
destination=dumpfile;
live=true; // TODO avoid // in URL
}
if ( errorCount > 0 )
_logger( message="#errorCount# benchmark(s) failed", throw=true );
Expand Down
8 changes: 8 additions & 0 deletions custom/benchmark/report.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
q = queryNew( "version,java,type,time,runs,inspect,memory,throughput,_min,_max,_avg,_med,error,raw,_perc,exeLog" );
tests = structNew('ordered');
runs = [];
for ( f in files ){
systemOutput ( f, true );
Expand Down Expand Up @@ -35,6 +36,11 @@
});
}
}
arrayAppend( runs, {
"java": json.run.javaVersion,
"version": json.run.version,
"totalDuration": json.run.totalDuration
});
}
benchmarkUtils = new benchmarkUtils();
Expand All @@ -48,6 +54,8 @@
_logger( "## Summary Report" );
reportRuns( runs );
if ( len( exeLog ) && exeLog neq "none" ){
_logger( "" );
_logger( "Note: ExecutionLog was set to [#exeLog#], not all versions run with executionLog enabled and it affects overall performance" );
Expand Down

0 comments on commit 7a8d2c4

Please sign in to comment.