ident: system identifier generator
This is pretty fast and guarantees uniqueness when initialised correctly. Signed-off-by: Yonah <contrib@gensokyo.uk>
This commit is contained in:
@@ -89,8 +89,10 @@ func TestFS(t *testing.T) {
|
||||
|
||||
{"valid", ident.F[ident.S, *ident.S]{
|
||||
I: &ident.S{
|
||||
Site: ident.TrivialSite,
|
||||
Host: ident.TrivialHost,
|
||||
PartG: ident.PartG{
|
||||
Site: ident.TrivialSite,
|
||||
Host: ident.TrivialHost,
|
||||
},
|
||||
|
||||
Time: uint64(time.Date(
|
||||
0xfd, 7, 15,
|
||||
@@ -130,8 +132,10 @@ func TestFM(t *testing.T) {
|
||||
},
|
||||
|
||||
System: ident.S{
|
||||
Site: ident.TrivialSite,
|
||||
Host: ident.TrivialHost,
|
||||
PartG: ident.PartG{
|
||||
Site: ident.TrivialSite,
|
||||
Host: ident.TrivialHost,
|
||||
},
|
||||
|
||||
Time: uint64(time.Date(
|
||||
0xfd, 7, 15,
|
||||
@@ -207,3 +211,19 @@ func TestErrors(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGeneratorS(b *testing.B) {
|
||||
var s ident.S
|
||||
g := ident.New(ident.TrivialSite, ident.TrivialHost)
|
||||
for b.Loop() {
|
||||
g.S(&s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGeneratorM(b *testing.B) {
|
||||
var pm ident.PartM
|
||||
g := ident.New(ident.TrivialSite, ident.TrivialHost)
|
||||
for b.Loop() {
|
||||
g.M(&pm, 0xbadf00d)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user