Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Avoid allocations by not calling custom functions on hot path #1289

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

anderseknert
Copy link
Member

This is absolutely wild 🙃

Before

BenchmarkRegalLintingItself-10	1	3245668375 ns/op	6689411656 B/op	127195706 allocs/op

After

BenchmarkRegalLintingItself-10  1	2777580459 ns/op	5235852824 B/op	107686435 allocs/op

And

hyperfine -i --warmup 1 'regal lint bundle' 'regal-new lint bundle'
Benchmark 1: regal lint bundle
  Time (mean ± σ):      3.232 s ±  0.046 s    [User: 22.535 s, System: 0.623 s]
  Range (min … max):    3.169 s …  3.296 s    10 runs

Benchmark 2: regal-new lint bundle
  Time (mean ± σ):      2.754 s ±  0.046 s    [User: 18.641 s, System: 0.472 s]
  Range (min … max):    2.689 s …  2.813 s    10 runs

Summary
  regal-new lint bundle ran
    1.17 ± 0.03 times faster than regal lint bundle

No @srenatus, I will not use benchstat! 🤣

This is absolutely wild 🙃

**Before**
```
BenchmarkRegalLintingItself-10	1	3245668375 ns/op	6689411656 B/op	127195706 allocs/op
```

**After**
```
BenchmarkRegalLintingItself-10  1	2777580459 ns/op	5235852824 B/op	107686435 allocs/op
```

And
```
hyperfine -i --warmup 1 'regal lint bundle' 'regal-new lint bundle'
Benchmark 1: regal lint bundle
  Time (mean ± σ):      3.232 s ±  0.046 s    [User: 22.535 s, System: 0.623 s]
  Range (min … max):    3.169 s …  3.296 s    10 runs

Benchmark 2: regal-new lint bundle
  Time (mean ± σ):      2.754 s ±  0.046 s    [User: 18.641 s, System: 0.472 s]
  Range (min … max):    2.689 s …  2.813 s    10 runs

Summary
  regal-new lint bundle ran
    1.17 ± 0.03 times faster than regal lint bundle
```

No @srenatus, I will not use benchstat! 🤣

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert merged commit 0db5b5f into main Dec 6, 2024
5 checks passed
@anderseknert anderseknert deleted the save-allocations branch December 6, 2024 10:35
charlieegan3 pushed a commit to charlieegan3/regal that referenced this pull request Jan 6, 2025
…nc#1289)

This is absolutely wild 🙃

**Before**
```
BenchmarkRegalLintingItself-10	1	3245668375 ns/op	6689411656 B/op	127195706 allocs/op
```

**After**
```
BenchmarkRegalLintingItself-10  1	2777580459 ns/op	5235852824 B/op	107686435 allocs/op
```

And
```
hyperfine -i --warmup 1 'regal lint bundle' 'regal-new lint bundle'
Benchmark 1: regal lint bundle
  Time (mean ± σ):      3.232 s ±  0.046 s    [User: 22.535 s, System: 0.623 s]
  Range (min … max):    3.169 s …  3.296 s    10 runs

Benchmark 2: regal-new lint bundle
  Time (mean ± σ):      2.754 s ±  0.046 s    [User: 18.641 s, System: 0.472 s]
  Range (min … max):    2.689 s …  2.813 s    10 runs

Summary
  regal-new lint bundle ran
    1.17 ± 0.03 times faster than regal lint bundle
```

No @srenatus, I will not use benchstat! 🤣

Signed-off-by: Anders Eknert <anders@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants