-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5ebcda
commit 7bf832e
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package colorjson_test | ||
|
||
import "testing" | ||
import "github.com/TylerBrock/colorjson" | ||
import "github.com/hokaccha/go-prettyjson" | ||
|
||
func benchmarkMarshall(i int, b *testing.B) { | ||
simpleMap := make(map[string]interface{}) | ||
simpleMap["a"] = 1 | ||
simpleMap["b"] = "bee" | ||
|
||
// run the Fib function b.N times | ||
for n := 0; n < b.N; n++ { | ||
colorjson.Marshal(simpleMap) | ||
} | ||
} | ||
|
||
func benchmarkPrettyJSON(i int, b *testing.B) { | ||
simpleMap := make(map[string]interface{}) | ||
simpleMap["a"] = 1 | ||
simpleMap["b"] = "bee" | ||
|
||
// run the Fib function b.N times | ||
for n := 0; n < b.N; n++ { | ||
prettyjson.Marshal(simpleMap) | ||
} | ||
} | ||
|
||
func BenchmarkMarshall(b *testing.B) { benchmarkMarshall(100, b) } | ||
func BenchmarkMarshall1k(b *testing.B) { benchmarkMarshall(1000, b) } | ||
func BenchmarkPrettyJSON(b *testing.B) { benchmarkPrettyJSON(100, b) } | ||
func BenchmarkPrettyJSON1k(b *testing.B) { benchmarkPrettyJSON(1000, b) } |