~samwhited/xmpp

ref: 8fb8d7def0c62a960ae1a0d95fa49646f303aedd xmpp/jid/benchmark_test.go -rw-r--r-- 1.2 KiB
8fb8d7deSam Whited Make Bare() part of the JID interface 6 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2014 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.

package jid

import (
	"testing"
)

func BenchmarkSplit(b *testing.B) {
	for i := 0; i < b.N; i++ {
		SplitString("user@example.com/resource")
	}
}

func BenchmarkUnsafeFromString(b *testing.B) {
	for i := 0; i < b.N; i++ {
		UnsafeFromString("user@example.com/resource")
	}
}

func BenchmarkUnsafeFromStringIPv4(b *testing.B) {
	for i := 0; i < b.N; i++ {
		UnsafeFromString("user@127.0.0.1/resource")
	}
}

func BenchmarkUnsafeFromStringIPv6(b *testing.B) {
	for i := 0; i < b.N; i++ {
		UnsafeFromString("user@[::1]/resource")
	}
}

func BenchmarkUnsafeFromParts(b *testing.B) {
	for i := 0; i < b.N; i++ {
		UnsafeFromParts("user", "example.com", "resource")
	}
}

func BenchmarkCopy(b *testing.B) {
	j := &UnsafeJID{"user", "example.com", "resource"}
	for i := 0; i < b.N; i++ {
		j.Copy()
	}
}

func BenchmarkBare(b *testing.B) {
	j := &UnsafeJID{"user", "example.com", "resource"}
	for i := 0; i < b.N; i++ {
		j.Bare()
	}
}

func BenchmarkString(b *testing.B) {
	j := &UnsafeJID{"user", "example.com", "resource"}
	for i := 0; i < b.N; i++ {
		j.String()
	}
}