2626
2727
2828def parse_args ():
29- parser = argparse .ArgumentParser (description = "Generate benchmark summary from JMH JSON" )
29+ parser = argparse .ArgumentParser (
30+ description = "Generate benchmark summary from JMH JSON"
31+ )
3032 parser .add_argument (
3133 "--input" ,
3234 default = "benchmark-results.json" ,
@@ -47,8 +49,8 @@ def parse_args():
4749
4850def get_system_info () -> Dict [str , str ]:
4951 """Capture system hardware information."""
50- import platform
5152 import multiprocessing
53+ import platform
5254
5355 info = {}
5456
@@ -67,9 +69,12 @@ def get_system_info() -> Dict[str, str]:
6769 # macOS
6870 try :
6971 import subprocess
72+
7073 result = subprocess .run (
7174 ["sysctl" , "-n" , "machdep.cpu.brand_string" ],
72- capture_output = True , text = True , timeout = 5
75+ capture_output = True ,
76+ text = True ,
77+ timeout = 5 ,
7378 )
7479 if result .returncode == 0 :
7580 info ["cpu_model" ] = result .stdout .strip ()
@@ -87,9 +92,12 @@ def get_system_info() -> Dict[str, str]:
8792 # macOS
8893 try :
8994 import subprocess
95+
9096 result = subprocess .run (
9197 ["sysctl" , "-n" , "hw.memsize" ],
92- capture_output = True , text = True , timeout = 5
98+ capture_output = True ,
99+ text = True ,
100+ timeout = 5 ,
93101 )
94102 if result .returncode == 0 :
95103 bytes_mem = int (result .stdout .strip ())
@@ -176,7 +184,9 @@ def generate_markdown(results: List, commit_sha: str, repo: str) -> str:
176184 md .append ("" )
177185 md .append (f"- **Date:** { datetime_str } " )
178186 if commit_sha != "local" :
179- md .append (f"- **Commit:** [`{ commit_short } `](https://github.com/{ repo } /commit/{ commit_sha } )" )
187+ md .append (
188+ f"- **Commit:** [`{ commit_short } `](https://github.com/{ repo } /commit/{ commit_sha } )"
189+ )
180190 else :
181191 md .append (f"- **Commit:** `{ commit_short } ` (local run)" )
182192 md .append (f"- **JDK:** { jdk_version } ({ vm_name } )" )
@@ -222,13 +232,17 @@ def generate_markdown(results: List, commit_sha: str, repo: str) -> str:
222232 sorted_benchmarks = sorted (
223233 benchmarks ,
224234 key = lambda x : x .get ("primaryMetric" , {}).get ("score" , 0 ),
225- reverse = True
235+ reverse = True ,
226236 )
227237
228238 md .append ("| Benchmark | Score | Error | Units | |" )
229239 md .append ("|:----------|------:|------:|:------|:---|" )
230240
231- best_score = sorted_benchmarks [0 ].get ("primaryMetric" , {}).get ("score" , 1 ) if sorted_benchmarks else 1
241+ best_score = (
242+ sorted_benchmarks [0 ].get ("primaryMetric" , {}).get ("score" , 1 )
243+ if sorted_benchmarks
244+ else 1
245+ )
232246
233247 for i , b in enumerate (sorted_benchmarks ):
234248 name = b .get ("benchmark" , "" ).split ("." )[- 1 ]
@@ -252,14 +266,18 @@ def generate_markdown(results: List, commit_sha: str, repo: str) -> str:
252266 except (ValueError , TypeError , ZeroDivisionError ):
253267 relative_fmt = ""
254268
255- md .append (f"| { name } | { score_fmt } | { error_fmt } | { unit } | { relative_fmt } |" )
269+ md .append (
270+ f"| { name } | { score_fmt } | { error_fmt } | { unit } | { relative_fmt } |"
271+ )
256272
257273 md .append ("" )
258274
259275 md .append ("### Raw Results" )
260276 md .append ("" )
261277 md .append ("```" )
262- md .append (f"{ 'Benchmark' :<50} { 'Mode' :>6} { 'Cnt' :>4} { 'Score' :>14} { 'Error' :>12} Units" )
278+ md .append (
279+ f"{ 'Benchmark' :<50} { 'Mode' :>6} { 'Cnt' :>4} { 'Score' :>14} { 'Error' :>12} Units"
280+ )
263281
264282 for b in sorted (results , key = lambda x : x .get ("benchmark" , "" )):
265283 name = b .get ("benchmark" , "" ).replace ("io.prometheus.metrics.benchmarks." , "" )
@@ -283,7 +301,9 @@ def generate_markdown(results: List, commit_sha: str, repo: str) -> str:
283301 except (ValueError , TypeError ):
284302 error_str = ""
285303
286- md .append (f"{ name :<50} { mode :>6} { cnt :>4} { score_str :>14} { error_str :>12} { unit } " )
304+ md .append (
305+ f"{ name :<50} { mode :>6} { cnt :>4} { score_str :>14} { error_str :>12} { unit } "
306+ )
287307
288308 md .append ("```" )
289309 md .append ("" )
0 commit comments