Skip to content

Commit 5dcc53b

Browse files
committed
fixup! chore: update benchmark result (#103)
1 parent 90440d7 commit 5dcc53b

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ result.txt
1313
testing/main.c
1414
*/*compile_commands.json
1515
testing/benchmark_results.txt
16-
testing/examples/*
16+
examples/*
1717

1818
# Ignore Python wheel packages (clang-format, clang-tidy)
1919
clang-tidy-1*

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ repos:
195195
| Supports passing code string | ✅ via `--style` | ❌ |
196196
| Verbose output | ✅ via `--verbose` | ❌ |
197197

198-
> [!TIP]
199-
> In most cases, there is no significant performance difference between `cpp-linter-hooks` and `mirrors-clang-format`. See the [benchmark results](testing/benchmark.md) for details.
198+
<!-- > [!TIP]
199+
> In most cases, there is no significant performance difference between `cpp-linter-hooks` and `mirrors-clang-format`. See the [benchmark results](testing/benchmark.md) for details. -->
200200

201201
## Contributing
202202

testing/benchmark.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Benchmark Results:
1818

1919
Hook | Avg (s) | Std (s) | Min (s) | Max (s) | Runs
2020
---------------------+------------------+------------------+------------------+------------------+-----------------
21-
mirrors-clang-format | 0.116 | 0.003 | 0.113 | 0.118 | 5
22-
cpp-linter-hooks | 0.114 | 0.003 | 0.109 | 0.117 | 5
21+
cpp-linter-hooks | 12.473 | 1.738 | 11.334 | 15.514 | 5
22+
mirrors-clang-format | 4.960 | 0.229 | 4.645 | 5.284 | 5
2323

2424
Results saved to testing/benchmark_results.txt
2525
```

testing/benchmark_hook_1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
2+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
33
rev: v1.1.0
44
hooks:
55
- id: clang-format

testing/benchmark_hooks.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
HOOKS = [
2222
{
23-
"name": "mirrors-clang-format",
24-
"config": "testing/benchmark_hook_2.yaml",
23+
"name": "cpp-linter-hooks",
24+
"config": "../testing/benchmark_hook_1.yaml",
2525
},
2626
{
27-
"name": "cpp-linter-hooks",
28-
"config": "testing/benchmark_hook_1.yaml",
27+
"name": "mirrors-clang-format",
28+
"config": "../testing/benchmark_hook_2.yaml",
2929
},
3030
]
3131

@@ -35,15 +35,14 @@
3535

3636
def prepare_code():
3737
try:
38-
subprocess.run(["rm", "-rf", "testing/examples"], check=True)
3938
subprocess.run(
4039
[
4140
"git",
4241
"clone",
4342
"--depth",
4443
"1",
4544
"https://github.com/gouravthakur39/beginners-C-program-examples.git",
46-
"testing/examples",
45+
"examples",
4746
],
4847
check=True,
4948
)
@@ -65,12 +64,13 @@ def run_hook(config):
6564

6665
def benchmark():
6766
results = {}
68-
os.chdir("testing/examples")
67+
prepare_code()
68+
os.chdir("examples")
6969
for hook in HOOKS:
70+
subprocess.run(["git", "restore", "."], check=True)
7071
times = []
7172
print(f"\nBenchmarking {hook['name']}...")
7273
for i in range(REPEATS):
73-
prepare_code()
7474
subprocess.run(["pre-commit", "clean"])
7575
t = run_hook(hook["config"])
7676
print(f" Run {i + 1}: {t:.3f} seconds")
@@ -108,6 +108,7 @@ def report(results):
108108
print(" | ".join(row))
109109
lines.append(" | ".join(row))
110110
# Save to file
111+
os.chdir("..")
111112
with open(RESULTS_FILE, "w") as f:
112113
f.write(header_row + "\n")
113114
f.write("-+-".join("-" * w for w in col_widths) + "\n")

testing/benchmark_results.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ Benchmark Results:
22

33
Hook | Avg (s) | Std (s) | Min (s) | Max (s) | Runs
44
---------------------+------------------+------------------+------------------+------------------+-----------------
5-
mirrors-clang-format | 0.116 | 0.003 | 0.113 | 0.118 | 5
6-
cpp-linter-hooks | 0.114 | 0.003 | 0.109 | 0.117 | 5
7-
8-
Results saved to testing/benchmark_results.txt
5+
cpp-linter-hooks | 12.473 | 1.738 | 11.334 | 15.514 | 5
6+
mirrors-clang-format | 4.960 | 0.229 | 4.645 | 5.284 | 5

0 commit comments

Comments
 (0)