Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions .github/workflows/codeql.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/ios.yml

This file was deleted.

30 changes: 18 additions & 12 deletions simple_seismic_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
from datetime import datetime
import time

# Pre-serialized responses
STATIC_ROOT_RESPONSE = json.dumps({
"service": "Genesis Seismic Log",
"version": "1.0.0",
"status": "operational",
"protocol": "S-ToT (Seismic Tree-of-Thoughts)",
"endpoints": {
"live": "/api/bench/live",
"health": "/api/health",
"seismic": "/api/seismic/status"
}
}, separators=(',', ':')).encode()

# System metrics
SYSTEM_METRICS = {
"hash_throughput_ops_sec": 15265,
Expand All @@ -25,17 +38,7 @@
class SeismicHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == "/":
self.send_json({
"service": "Genesis Seismic Log",
"version": "1.0.0",
"status": "operational",
"protocol": "S-ToT (Seismic Tree-of-Thoughts)",
"endpoints": {
"live": "/api/bench/live",
"health": "/api/health",
"seismic": "/api/seismic/status"
}
})
self.send_json(STATIC_ROOT_RESPONSE)
elif self.path == "/api/health":
self.send_json({
"status": "healthy",
Expand Down Expand Up @@ -112,7 +115,10 @@ def send_json(self, data):
self.send_header('Content-Type', 'application/json')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
self.wfile.write(json.dumps(data, separators=(',', ':')).encode())
if isinstance(data, bytes):
self.wfile.write(data)
else:
self.wfile.write(json.dumps(data, separators=(',', ':')).encode())

def log_message(self, format, *args):
"""Override to customize logging"""
Expand Down
37 changes: 37 additions & 0 deletions test_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import urllib.request
import time
import threading

URL = "http://localhost:8003/"
NUM_REQUESTS = 1000

def make_requests():
for _ in range(NUM_REQUESTS):
try:
urllib.request.urlopen(URL).read()
except Exception:
pass
Comment on lines +12 to +13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a broad except Exception: pass silently swallows all errors. This can be misleading, as the benchmark might report success even if all requests are failing due to network issues, server errors, or other problems. It's better to at least log the error to be aware of any issues during the benchmark run.

Suggested change
except Exception:
pass
except Exception as e:
print(f"Request failed: {e}")

Comment on lines +12 to +13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Silently ignoring all exceptions with except Exception: pass can make the benchmark results misleading. If the server is down or returns errors, the script will not report any issues, and the calculated RPS will be based on a potentially lower number of successful requests than intended, or worse, based on time spent failing. It's better to at least log the errors or count them to get an accurate picture of the server's performance and health.

Suggested change
except Exception:
pass
except Exception as e:
print(f"Request failed: {e}")


def run_benchmark():
threads = []
start_time = time.time()

for _ in range(10):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The number of threads (10) is hardcoded. This value is used again on line 29 for calculating total_requests. Using a named constant (e.g., NUM_THREADS) at the top of the file would improve readability and maintainability, preventing potential inconsistencies if the number of threads is changed in one place but not the other.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The number of threads (10) is hardcoded here and again on line 29 when calculating total_requests. This use of a 'magic number' makes the script harder to modify and understand. If you wanted to change the number of threads, you would have to find and update it in multiple places, which is error-prone.

It would be better to define the number of threads as a constant at the top of the script, similar to URL and NUM_REQUESTS.

t = threading.Thread(target=make_requests)
threads.append(t)
t.start()

for t in threads:
t.join()

end_time = time.time()
duration = end_time - start_time
total_requests = NUM_REQUESTS * 10
rps = total_requests / duration

print(f"Total Requests: {total_requests}")
print(f"Duration: {duration:.2f} seconds")
print(f"Requests per Second: {rps:.2f}")

if __name__ == "__main__":
run_benchmark()
Loading