projects
/
go-signalcontext.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve Error.Error() performance
[go-signalcontext.git]
/
error_test.go
diff --git
a/error_test.go
b/error_test.go
index
eb347ef
..
dc90e0e
100644
(file)
--- a/
error_test.go
+++ b/
error_test.go
@@
-11,3
+11,12
@@
func TestError(t *testing.T) {
assert.EqualError(t, Error{os.Interrupt},
"received signal: "+os.Interrupt.String())
}
assert.EqualError(t, Error{os.Interrupt},
"received signal: "+os.Interrupt.String())
}
+
+func BenchmarkError(b *testing.B) {
+ expected := "received signal: " + os.Interrupt.String()
+ for i := 0; i < b.N; i++ {
+ if s := (Error{os.Interrupt}).String(); s != expected {
+ b.Fatalf("expected %s, got %s", s, expected)
+ }
+ }
+}