Skip to content

Commit

Permalink
add simple benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jul 15, 2024
1 parent 927f1ab commit d4ad256
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Simple benchmarking

on:
workflow_dispatch:
workflow_call:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
luceeVersion: [ 5.4/snapshot/jar, 6.0/snapshot/jar, 6.1/snapshot/jar, 6.1.0/snapshot/jar, 6.2/snapshot/jar ]
javaVersion: [ 11, 21 ]
exclude:
- luceeVersion: 5.4/snapshot/jar
javaVersion: 21
- luceeVersion: 6.0/snapshot/jar
javaVersion: 21
env:
luceeVersionQuery: ${{ matrix.luceeVersion }}
compile: ${{ github.event.inputs.compile }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{matrix.javaVersion}}
uses: actions/setup-java@v4
with:
java-version: ${{matrix.javaVersion}}
distribution: "temurin"
- name: Cache Maven packages
if: always()
uses: actions/cache@v4
with:
path: ~/.m2
key: maven-cache
- name: Cache Lucee files
uses: actions/cache@v4
if: always()
with:
path: /home/runner/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads
- name: Run Microbenches
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/custom/benchmark
execute: /index.cfm
luceeVersionQuery: ${{ matrix.luceeVersion }}

3 changes: 3 additions & 0 deletions custom/benchmark/Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
component {
this.name="bench-runner";
}
34 changes: 34 additions & 0 deletions custom/benchmark/index.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<cfscript>
runs = server.system.environment.BENCHMARK_CYCLES ?: 10000;
arr = [];
systemOutput("Running hello world [#runs#] times", true);
ArraySet( arr, 1, runs, 0 );
s = getTickCount();
ArrayEach( function( item ){
InternalRequest(
url: "/tests/hello-world.cfm"
);
}, true );
time = getTickCount()-s;
function _logger( string message="", boolean throw=false ){
systemOutput( arguments.message, true );
if ( !FileExists( server.system.environment.GITHUB_STEP_SUMMARY ) ){
fileWrite( server.system.environment.GITHUB_STEP_SUMMARY, "#### #server.lucee.version# ");
fileAppend( server.system.environment.GITHUB_STEP_SUMMARY, server.system.environment.toJson());
}
if ( arguments.throw ) {
fileAppend( server.system.environment.GITHUB_STEP_SUMMARY, "> [!WARNING]" & chr(10) );
fileAppend( server.system.environment.GITHUB_STEP_SUMMARY, "> #arguments.message##chr(10)#");
throw arguments.message;
} else {
fileAppend( server.system.environment.GITHUB_STEP_SUMMARY, " #arguments.message##chr(10)#");
}
}
_logger( "Running hello world [#runs#] times, took #numberFormat(time)# ms, or #numberFormat(runs/(time/1000))# per second" );
</cfscript>
3 changes: 3 additions & 0 deletions custom/benchmark/tests/Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
component {
this.name="bench";
}
3 changes: 3 additions & 0 deletions custom/benchmark/tests/hello-world.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<cfheader name="Server" value="cfml-lucee">
<cfheader name="Content-Type" value="text/plain">
<cfcontent reset="true">Hello, World!

0 comments on commit d4ad256

Please sign in to comment.