22// Each block measures runtime only and prints: workload|name|checksum=...|elapsed=...ms
33use os;
44use math;
5- use map;
6- use string;
75
86let seed = os.epoch();
97let workload_filter = os.env.get("LK_WORKLOAD_FILTER", "");
@@ -112,7 +110,7 @@ if should_run("two_sum_map") {
112110 for i in 1..=two_sum_width {
113111 let need = target - i;
114112 let need_key = "n${need}";
115- if map .get(seen, need_key) != nil {
113+ if seen .get(need_key) != nil {
116114 found += 1;
117115 }
118116 }
@@ -201,7 +199,7 @@ if should_run("histogram_group_count") {
201199 for i in 1..=hist_n {
202200 let bucket = ((i * 17) + r) % 32;
203201 let key = "b${bucket}";
204- let prev = map .get(hist, key);
202+ let prev = hist .get(key);
205203 if prev == nil {
206204 hist.set(key, 1);
207205 } else {
@@ -210,7 +208,7 @@ if should_run("histogram_group_count") {
210208 }
211209 for b in 0..32 {
212210 let key = "b${b}";
213- let v = map .get(hist, key);
211+ let v = hist .get(key);
214212 if v != nil {
215213 checksum += v * v;
216214 }
@@ -266,7 +264,7 @@ if should_run("log_parse_filter") {
266264 let line = "ts=${r}|tenant=t${i % 13}|status=error|path=/api/v1/orders/${i % 19}";
267265 let parsed_len = line.split("|").join("|").len();
268266 checksum += parsed_len % 7;
269- let prev = map .get(status_counts, "error");
267+ let prev = status_counts .get("error");
270268 if prev == nil {
271269 status_counts.set("error", 1);
272270 } else {
@@ -276,7 +274,7 @@ if should_run("log_parse_filter") {
276274 let line = "ts=${r}|tenant=t${i % 13}|status=warn|path=/api/v1/orders/${i % 19}";
277275 let parsed_len = line.split("|").join("|").len();
278276 checksum += parsed_len % 7;
279- let prev = map .get(status_counts, "warn");
277+ let prev = status_counts .get("warn");
280278 if prev == nil {
281279 status_counts.set("warn", 1);
282280 } else {
@@ -286,17 +284,17 @@ if should_run("log_parse_filter") {
286284 let line = "ts=${r}|tenant=t${i % 13}|status=${status}|path=/api/v1/orders/${i % 19}";
287285 let parsed_len = line.split("|").join("|").len();
288286 checksum += parsed_len % 7;
289- let prev = map .get(status_counts, status);
287+ let prev = status_counts .get(status);
290288 if prev == nil {
291289 status_counts.set(status, 1);
292290 } else {
293291 status_counts.set(status, prev + 1);
294292 }
295293 }
296294 }
297- let ok_count = map .get(status_counts, "ok");
298- let warn_count = map .get(status_counts, "warn");
299- let error_count = map .get(status_counts, "error");
295+ let ok_count = status_counts .get("ok");
296+ let warn_count = status_counts .get("warn");
297+ let error_count = status_counts .get("error");
300298 if ok_count != nil { checksum += ok_count; }
301299 if warn_count != nil { checksum += warn_count * 7; }
302300 if error_count != nil { checksum += error_count * 31; }
@@ -306,8 +304,8 @@ if should_run("log_parse_filter") {
306304}
307305
308306fn cart_line_total(sku, qty, region, prices, tax_rates) {
309- let price = map .get(prices, sku);
310- let tax = map .get(tax_rates, region);
307+ let price = prices .get(sku);
308+ let tax = tax_rates .get(region);
311309 let subtotal = price * qty;
312310 let discount = 0;
313311 if qty >= 5 {
@@ -349,15 +347,15 @@ if should_run("route_permission_check") {
349347 let role_levels = {"guest": 0, "user": 10, "analyst": 40, "ops": 70, "admin": 100};
350348 for i in 1..=route_rounds {
351349 if ((i % 11) == 0) {
352- checksum += (i % 97) + map .get(role_levels, "admin") + "/admin/users".len();
350+ checksum += (i % 97) + role_levels .get("admin") + "/admin/users".len();
353351 } else if ((i % 7) == 0) {
354- checksum += (i % 97) + map .get(role_levels, "ops") + "DELETE".len();
352+ checksum += (i % 97) + role_levels .get("ops") + "DELETE".len();
355353 } else if ((i % 5) == 0) {
356- checksum += (i % 97) + map .get(role_levels, "analyst") + "/reports/daily".len();
354+ checksum += (i % 97) + role_levels .get("analyst") + "/reports/daily".len();
357355 } else if ((i % 2) == 0) {
358- checksum += (i % 97) + map .get(role_levels, "user") + "/api/orders".len();
356+ checksum += (i % 97) + role_levels .get("user") + "/api/orders".len();
359357 } else {
360- checksum += 3 + map .get(role_levels, "guest");
358+ checksum += 3 + role_levels .get("guest");
361359 }
362360 }
363361 t1 = os.clock();
@@ -373,7 +371,7 @@ if should_run("inventory_reorder") {
373371 let reorder = [];
374372 for i in 1..=64 {
375373 let sku = "sku-${i % 23}";
376- let current = map .get(stock, sku);
374+ let current = stock .get(sku);
377375 let delta = ((i * 11) + r) % 37;
378376 if current == nil {
379377 stock.set(sku, delta);
@@ -383,7 +381,7 @@ if should_run("inventory_reorder") {
383381 }
384382 for i in 0..23 {
385383 let sku = "sku-${i}";
386- let available = map .get(stock, sku);
384+ let available = stock .get(sku);
387385 if available == nil {
388386 available = 0;
389387 }
@@ -408,7 +406,7 @@ fn fraud_score(amount, country, device, prior_declines, risky_countries) {
408406 } else if amount > 400 {
409407 score += 15;
410408 }
411- if map .get(risky_countries, country) != nil {
409+ if risky_countries .get(country) != nil {
412410 score += 35;
413411 }
414412 if device.starts_with("emu") {
@@ -511,9 +509,9 @@ if should_run("event_join_by_id") {
511509 }
512510 for e in 0..event_n {
513511 let uid = "u${(e * 7 + r) % user_n}";
514- let quota = map .get(user_quotas, uid);
512+ let quota = user_quotas .get(uid);
515513 if quota != nil {
516- let plan = map .get(user_plans, uid);
514+ let plan = user_plans .get(uid);
517515 checksum += quota % 31;
518516 if plan == 3 {
519517 checksum += 41;
@@ -539,13 +537,13 @@ if should_run("config_defaults_merge") {
539537 if ((i % 3) == 0) { config.set("timeout", 30 + (i % 17)); }
540538 if ((i % 5) == 0) { config.set("region", 2); }
541539 if ((i % 7) == 0) { config.set("mode", 2); }
542- let retries = map .get(config, "retries");
540+ let retries = config .get("retries");
543541 if retries == nil { retries = 3; }
544- let timeout = map .get(config, "timeout");
542+ let timeout = config .get("timeout");
545543 if timeout == nil { timeout = 25; }
546- let region = map .get(config, "region");
544+ let region = config .get("region");
547545 if region == nil { region = 1; }
548- let mode = map .get(config, "mode");
546+ let mode = config .get("mode");
549547 if mode == nil { mode = 1; }
550548 checksum += retries * 13 + timeout;
551549 if region == 2 { checksum += 17; } else { checksum += 5; }
0 commit comments