migrated to simplelog
This commit is contained in:
parent
3c2395568e
commit
1b4c76c3a1
@ -1,9 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
log "git.staur.ca/stobbsm/simplelog"
|
||||||
"git.staur.ca/stobbsm/tind"
|
"git.staur.ca/stobbsm/tind"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,14 +16,14 @@ const runs uint64 = 10000
|
|||||||
// CollisionChecks runs different tests to check for collisions, and get's the average
|
// CollisionChecks runs different tests to check for collisions, and get's the average
|
||||||
func CollisionChecks() {
|
func CollisionChecks() {
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
log.Println("Using multiple configurations, test for collisions multiple times")
|
log.Info("examples.CollisionChecks").Msg("Using multiple configurations, test for collisions multiple times")
|
||||||
sizes := []int{4,5,6,7,8,9,10,11,12,13,14,15,16}
|
sizes := []int{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
||||||
end := len(RuneSet)
|
end := len(RuneSet)
|
||||||
|
|
||||||
for i := 4; i < end; i++ {
|
for i := 4; i < end; i++ {
|
||||||
for _, v := range sizes {
|
for _, v := range sizes {
|
||||||
v := v
|
v := v
|
||||||
rs :=RuneSet[:i]
|
rs := RuneSet[:i]
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go collisionCheck(v, rs, wg, len(rs))
|
go collisionCheck(v, rs, wg, len(rs))
|
||||||
}
|
}
|
||||||
@ -37,7 +37,11 @@ func collisionCheck(size int, runeset []rune, wg *sync.WaitGroup, runesize int)
|
|||||||
for i := uint64(0); i < runs; i++ {
|
for i := uint64(0); i < runs; i++ {
|
||||||
total += runCheck(tind.New().WithSize(size).WithRuneset(runeset))
|
total += runCheck(tind.New().WithSize(size).WithRuneset(runeset))
|
||||||
}
|
}
|
||||||
log.Printf("runset size: %d, id size: %d, average iterations before collision: %d", runesize, size, total/runs)
|
log.Info("examples.collisionCheck").
|
||||||
|
Uint64("average iterations", total/runs).
|
||||||
|
Int("runesize", runesize).
|
||||||
|
Int("size", size).
|
||||||
|
Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCheck(tconfig *tind.Config) uint64 {
|
func runCheck(tconfig *tind.Config) uint64 {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
log "git.staur.ca/stobbsm/simplelog"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("Example: GenWithDefaults")
|
log.Info("examples.main").Msg("Example: GenWithDefaults")
|
||||||
GenWithDefaults()
|
GenWithDefaults()
|
||||||
|
|
||||||
log.Println("Example: CollisionChecks")
|
log.Info("examples.main").Msg("Example: CollisionChecks")
|
||||||
CollisionChecks()
|
CollisionChecks()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
log "git.staur.ca/stobbsm/simplelog"
|
||||||
|
)
|
||||||
|
|
||||||
func ReallyLongRuneset() {
|
func ReallyLongRuneset() {
|
||||||
log.Println("Really long runeset")
|
log.Info("examples.ReallyLongRuneset").Msg("Really long runeset")
|
||||||
}
|
}
|
||||||
|
11
tind_test.go
11
tind_test.go
@ -1,9 +1,10 @@
|
|||||||
package tind
|
package tind
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "git.staur.ca/stobbsm/simplelog"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "git.staur.ca/stobbsm/simplelog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_GenTinD_With_Defaults(t *testing.T) {
|
func Test_GenTinD_With_Defaults(t *testing.T) {
|
||||||
@ -64,10 +65,14 @@ func checkCollisions(tindSize int) {
|
|||||||
}
|
}
|
||||||
// Print a message every 2000000 iterations saying we are still working
|
// Print a message every 2000000 iterations saying we are still working
|
||||||
if iters%2000000 == 0 {
|
if iters%2000000 == 0 {
|
||||||
log.Info("test.checkCollisions").uint64("iterations", iters).Int("size", tindSize).Msg("Still no collions")
|
log.Info("test.checkCollisions").Uint64("iterations", iters).Int("size", tindSize).Msg("Still no collions")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Info("test.checkCollisions").uint64("iterations", iters).Int("size", tindSize).Msg("Collision found", time.Since(start))
|
log.Info("test.checkCollisions").
|
||||||
|
Uint64("iterations", iters).
|
||||||
|
Int("size", tindSize).
|
||||||
|
Dur("duration", time.Since(start)).
|
||||||
|
Msg("Collision found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_GenerateConfigFromByteSlice(t *testing.T) {
|
func Test_GenerateConfigFromByteSlice(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user