Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,9 @@
package empty
func Empty() {}
func Count() {
// count to a million
for i := 0; i < 1e6; i++ {
}
}

View file

@ -0,0 +1,15 @@
package empty
import "testing"
func BenchmarkEmpty(b *testing.B) {
for i := 0; i < b.N; i++ {
Empty()
}
}
func BenchmarkCount(b *testing.B) {
for i := 0; i < b.N; i++ {
Count()
}
}

View file

@ -0,0 +1,31 @@
package main
import (
"fmt"
"testing"
)
func empty() {}
func count() {
for i := 0; i < 1e6; i++ {
}
}
func main() {
e := testing.Benchmark(func(b *testing.B) {
for i := 0; i < b.N; i++ {
empty()
}
})
c := testing.Benchmark(func(b *testing.B) {
for i := 0; i < b.N; i++ {
count()
}
})
fmt.Println("Empty function: ", e)
fmt.Println("Count to a million:", c)
fmt.Println()
fmt.Printf("Empty: %12.4f\n", float64(e.T.Nanoseconds())/float64(e.N))
fmt.Printf("Count: %12.4f\n", float64(c.T.Nanoseconds())/float64(c.N))
}

View file

@ -0,0 +1,25 @@
package main
import (
"fmt"
"time"
)
func from(t0 time.Time) {
fmt.Println(time.Now().Sub(t0))
}
func empty() {
defer from(time.Now())
}
func count() {
defer from(time.Now())
for i := 0; i < 1e6; i++ {
}
}
func main() {
empty()
count()
}