migrated to simplelog

This commit is contained in:
Matthew Stobbs 2024-04-07 12:27:05 -06:00
parent 3c2395568e
commit 1b4c76c3a1
4 changed files with 28 additions and 15 deletions

View File

@ -1,9 +1,9 @@
package main
import (
"log"
"sync"
log "git.staur.ca/stobbsm/simplelog"
"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
func CollisionChecks() {
wg := new(sync.WaitGroup)
log.Println("Using multiple configurations, test for collisions multiple times")
sizes := []int{4,5,6,7,8,9,10,11,12,13,14,15,16}
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}
end := len(RuneSet)
for i := 4; i < end; i++ {
for _, v := range sizes {
v := v
rs :=RuneSet[:i]
rs := RuneSet[:i]
wg.Add(1)
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++ {
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 {

View File

@ -1,11 +1,13 @@
package main
import "log"
import (
log "git.staur.ca/stobbsm/simplelog"
)
func main() {
log.Println("Example: GenWithDefaults")
log.Info("examples.main").Msg("Example: GenWithDefaults")
GenWithDefaults()
log.Println("Example: CollisionChecks")
log.Info("examples.main").Msg("Example: CollisionChecks")
CollisionChecks()
}

View File

@ -1,7 +1,9 @@
package main
import "log"
import (
log "git.staur.ca/stobbsm/simplelog"
)
func ReallyLongRuneset() {
log.Println("Really long runeset")
log.Info("examples.ReallyLongRuneset").Msg("Really long runeset")
}

View File

@ -1,9 +1,10 @@
package tind
import (
log "git.staur.ca/stobbsm/simplelog"
"testing"
"time"
log "git.staur.ca/stobbsm/simplelog"
)
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
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) {