Skip to content

Commit

Permalink
added luau benchmark scripts
Browse files Browse the repository at this point in the history
- dt_format.luau is used for the luau_multi benchmark
- turnaround_time.luau is used for the luau_script benchmark
- benchmark_aggregations.luau is used by the benchmark shell script to compute recs_per_sec and to aggregate mean to total_mean
  • Loading branch information
jqnatividad committed Sep 24, 2023
1 parent c146cf7 commit cb28ea3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/benchmark_aggregations.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- this is the BEGIN block, which is executed once before the main loop
BEGIN {
-- we initialize the variables here
total_mean = 0;
benchmark_data_rowcount=tonumber(qsv_getenv("QSVBM_ROWCOUNT"));

-- and setup helper functions
-- this one is to round a number to a given number of decimal places
function round(num, numDecimalPlaces)
return string.format("%." .. (numDecimalPlaces or 0) .. "f", num)
end
}!

-- this is the main loop, which is executed for each row
work_var = benchmark_data_rowcount / mean;
total_mean = total_mean + mean;

recs_per_sec=string.format("%.0f",work_var);
return recs_per_sec;

-- this is the end block, which is executed once after the main loop
END {
-- we return the total_mean here
-- note that this value is returned to stderr
return round(total_mean, 3);
}!
8 changes: 8 additions & 0 deletions scripts/dt_format.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local date = require "date";

createdate = date(col["Created Date"]);

dayofweek = createdate:fmt('%a');
hourofday = createdate:fmt('%H');
weeknumber = createdate:fmt('%W');
return {dayofweek, hourofday, weeknumber};
11 changes: 11 additions & 0 deletions scripts/turnaround_time.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- compute Turnaround Time for NYC 311 Benchmark data
local date = require "date"

if (string.len(col["Created Date"]) == 0 or string.len(col["Closed Date"]) == 0) then
return
end

local t_sdate = date(col["Created Date"])
local t_edate = date(col["Closed Date"])
local t_diff = date.diff(t_edate, t_sdate)
return t_diff:spandays()

0 comments on commit cb28ea3

Please sign in to comment.