Last active
December 3, 2016 02:01
-
-
Save nhooyr/9e049054393ccbf205f6e29ae385b398 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package main | |
| import ( | |
| "os" | |
| "testing" | |
| ) | |
| var d os.FileInfo | |
| var err error | |
| func BenchmarkStat(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| d, err = os.Stat("main_test.go") | |
| if err != nil { | |
| b.Fatal(err) | |
| } | |
| } | |
| } | |
| func BenchmarkOpenStat(b *testing.B) { | |
| var f *os.File | |
| for i := 0; i < b.N; i++ { | |
| f, err = os.Open("main_test.go") | |
| if err != nil { | |
| b.Fatal(err) | |
| } | |
| d, err = f.Stat() | |
| if err != nil { | |
| b.Fatal(err) | |
| } | |
| f.Close() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment