Skip to content

Commit 776c0e4

Browse files
committed
Benchmarking optimizations
Making this way faster by removing redundant builds and whatnot.
1 parent 10003d1 commit 776c0e4

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

benchmark.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import time
66

7-
def run_command(command, silent=False):
7+
def run_command(command, silent=False, dataset=None):
88
"""Runs a shell command."""
99
try:
1010
if silent:
@@ -89,14 +89,14 @@ def run_benchmark():
8989
selection, dataset = curses.wrapper(main)
9090
except Exception as e:
9191
print(f"Error in UI: {e}")
92-
run_command("make clean", silent=True)
92+
# run_command("make clean", silent=True)
9393
return
9494

9595
if selection == "Exit" or selection is None:
9696
if dataset and dataset != "Exit":
9797
print(dataset) # Print error message if any
9898
print("Exiting...")
99-
run_command("make clean", silent=True)
99+
# run_command("make clean", silent=True)
100100
return
101101

102102
print(f"\nRunning {selection} Benchmark with dataset: {dataset}\n" + "="*60 + "\n")
@@ -105,30 +105,36 @@ def run_benchmark():
105105
start_time = time.time()
106106

107107
# Pass dataset as ARGS
108-
args = f'ARGS="{dataset}"'
108+
# args = f'ARGS="{dataset}"'
109109

110+
# Run the executable of the select benchmark, avoid make rules for overhead concerns
110111
if selection == "Serial":
111-
run_command(f"make run {args}")
112+
run_command(f"./QPESeq {dataset}")
113+
112114
elif selection == "OMP":
113-
run_command(f"make run-omp {args}")
115+
run_command(f"./QPEOMP {dataset}")
116+
114117
elif selection == "MPI":
115-
run_command(f"make run-mpi {args}")
118+
run_command(f"./QPEMPI {dataset}")
119+
116120
elif selection == "ALL":
117121
print("--- Running Serial ---")
118-
run_command(f"make run {args}")
122+
run_command(f"./QPESeq {dataset}")
123+
119124
print("\n--- Running OMP ---")
120-
run_command(f"make run-omp {args}")
125+
run_command(f"./QPEOMP {dataset}")
126+
121127
print("\n--- Running MPI ---")
122-
run_command(f"make run-mpi {args}")
128+
run_command(f"./QPEMPI {dataset}")
123129

124130
end_time = time.time()
125131
print("\n" + "="*60)
126132
print(f"Total Benchmark Time: {end_time - start_time:.4f} seconds")
127133

128-
# Run make clean silently
129-
print("Cleaning up build artifacts...")
130-
run_command("make clean", silent=True)
131-
print("Done.")
134+
# # Run make clean silently
135+
# print("Cleaning up build artifacts...")
136+
# run_command("make clean", silent=True)
137+
# print("Done.")
132138

133139
if __name__ == "__main__":
134140
run_benchmark()

data-generation/commands_1m.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:4cc6c639d9d2bb85214cc75f365516e1b08e01b8f66f45e284372b9902467313
3-
size 119604509
2+
oid sha256:f971b4bd2192c287507ba438684a974d4b2b1b785b33119061126735ea9f0a83
3+
size 119604440

sample-queries-FULL.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -- SAMPLE SQL QUERIES --
2+
# -- Sample 1:
3+
SELECT command_id, base_command, sudo_used, user_name, timestamp
4+
FROM Commands
5+
WHERE sudo_used = FALSE AND user_name = "student1030";
6+
7+
# -- Sample 2:
8+
SELECT command_id, raw_command, user_name, risk_level, timestamp
9+
FROM Commands
10+
WHERE sudo_used = TRUE AND risk_level > 2;
11+
12+
# -- Sample 3:
13+
SELECT raw_command, exit_code, timestamp, sudo_used, user_name, risk_level
14+
FROM Commands
15+
WHERE risk_level > 3;
16+
17+
# -- Sample 4:
18+
SELECT *
19+
FROM Commands
20+
WHERE risk_level = 5;
21+
22+
# -- Sample 5:
23+
INSERT INTO Commands VALUES (999999, "echo 'test insert'", "echo", "bash", 0, "2025-12-01T12:00:00.000Z", "FALSE", "/home/test", 1000, "testuser", "test-host", 1);
24+
25+
# -- Sample 6:
26+
DELETE FROM Commands WHERE command_id = 999999;
27+
28+
# -- Sample 7:
29+
SELECT command_id, raw_command, risk_level, exit_code
30+
FROM Commands
31+
WHERE sudo_used = TRUE OR (risk_level = 5 AND shell_type = "bash");
32+
33+
# -- Sample 8:
34+
SELECT user_name, working_directory, base_command
35+
FROM Commands
36+
WHERE user_id = 1001 OR (user_name = "student1002" AND shell_type = "zsh");

sample-queries.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ WHERE risk_level = 5;
2222
# -- Sample 5:
2323
INSERT INTO Commands VALUES (999999, "echo 'test insert'", "echo", "bash", 0, "2025-12-01T12:00:00.000Z", "FALSE", "/home/test", 1000, "testuser", "test-host", 1);
2424

25-
# -- Sample 6:
26-
DELETE FROM Commands WHERE command_id = 999999;
27-
2825
# -- Sample 7:
2926
SELECT command_id, raw_command, risk_level, exit_code
3027
FROM Commands

0 commit comments

Comments
 (0)