Skip to content
Merged
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
76 changes: 42 additions & 34 deletions BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,55 @@ execution time, memory usage, and heap allocations.

## Methodology
Benchmarks are executed using the standard Go testing tool:
`go test -bench=. -benchmem -count=10 > bench_results.txt`
```shell
go test -bench=. -benchmem -count=10 > bench_results.txt
```

The results below are generated on:

* **OS:** macOS darwin
* **OS:** Darwin _(macOS)_
* **Architecture:** ARM64
* **CPU:** Apple M2
* **Go Version:** 1.24

BenchmarkSyniolLogger-8 1891555 611.1 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1957856 613.0 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1957063 615.2 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1886391 621.1 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1942413 614.8 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1951993 618.5 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1935925 617.1 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1897650 624.7 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1945797 630.0 ns/op 664 B/op 9 allocs/op
BenchmarkSyniolLogger-8 1942968 628.3 ns/op 664 B/op 9 allocs/op
BenchmarkSlogJSON-8 2352092 510.8 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2353771 509.9 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2380887 510.9 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2371741 507.7 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2364392 513.5 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2346122 508.3 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2375124 504.0 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2372458 505.7 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2375211 502.5 ns/op 0 B/op 0 allocs/op
BenchmarkSlogJSON-8 2354427 504.1 ns/op 0 B/op 0 allocs/op
BenchmarkSlogWithSource-8 1000000 1053 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1067 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1058 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1052 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1053 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1054 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1053 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1050 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1050 ns/op 584 B/op 6 allocs/op
BenchmarkSlogWithSource-8 1000000 1053 ns/op 584 B/op 6 allocs/op
PASS
ok github.com/syniol/go-logger 46.628s
| Benchmark Case | Iterations | Memory Allocations | Bytes Allocations | Operation Allocations |
|---------------------------|------------|--------------------|-------------------|-----------------------|
| BenchmarkSyniolLogger-8 | 1891555 | 611.1 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1957856 | 613.0 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1957063 | 615.2 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1886391 | 621.1 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1942413 | 614.8 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1951993 | 618.5 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1935925 | 617.1 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1897650 | 624.7 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1945797 | 630.0 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSyniolLogger-8 | 1942968 | 628.3 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSlogJSON-8 | 2352092 | 510.8 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2353771 | 509.9 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2380887 | 510.9 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2371741 | 507.7 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2364392 | 513.5 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2346122 | 508.3 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2375124 | 504.0 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2372458 | 505.7 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2375211 | 502.5 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogJSON-8 | 2354427 | 504.1 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1053 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1067 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1058 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1052 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1053 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1054 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1053 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1050 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1050 ns/op | 584 B/op | 6 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1053 ns/op | 584 B/op | 6 allocs/op |

```shell
PASS
ok github.com/syniol/go-logger 46.628s
```


### Comparison: logger vs. slog (Standard Library)
> **Note on the Trace Field:** Our logger captures the caller's file and line
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ sylog.LogError("order-processor", "Database connection timed out")
When this reaches **CloudWatch** or **Datadog**, you can simply run a query like facility:
"order-processor" to see the entire lifecycle of that specific service's behavior.

## Performance Benchmarks
The document that tracks the performance of the logger package is published in details
at the root of repository [`BENCHMARKS.md`](https://github.com/syniol/go-logger/blob/main/BENCHMARKS.md).


| Benchmark Case | Iterations | Memory Allocations | Bytes Allocations | Operation Allocations |
|---------------------------|------------|--------------------|-------------------|-----------------------|
| BenchmarkSyniolLogger-8 | 1891555 | 611.1 ns/op | 664 B/op | 9 allocs/op |
| BenchmarkSlogJSON-8 | 2352092 | 510.8 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkSlogWithSource-8 | 1000000 | 1053 ns/op | 584 B/op | 6 allocs/op |


#### Credits
Author: [Hadi Tajallaei](mailto:hadi@syniol.com)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/syniol/go-logger

go 1.18
go 1.21