Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
d673c95d
Commit
d673c95d
authored
Feb 02, 2012
by
Marcel van Lohuizen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exp/norm: Added some benchmarks for form-specific performance measurements.
R=r CC=golang-dev
https://golang.org/cl/5605051
parent
df7f34dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
src/pkg/exp/norm/normalize_test.go
src/pkg/exp/norm/normalize_test.go
+37
-7
No files found.
src/pkg/exp/norm/normalize_test.go
View file @
d673c95d
...
...
@@ -495,11 +495,11 @@ func TestAppend(t *testing.T) {
runAppendTests
(
t
,
"TestString"
,
NFKC
,
stringF
,
appendTests
)
}
func
doFormBenchmark
(
b
*
testing
.
B
,
f
Form
,
s
string
)
{
func
doFormBenchmark
(
b
*
testing
.
B
,
inf
,
f
Form
,
s
string
)
{
b
.
StopTimer
()
in
:=
[]
byte
(
s
)
in
:=
inf
.
Bytes
([]
byte
(
s
)
)
buf
:=
make
([]
byte
,
2
*
len
(
in
))
b
.
SetBytes
(
int64
(
len
(
s
)))
b
.
SetBytes
(
int64
(
len
(
in
)))
b
.
StartTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
buf
=
f
.
Append
(
buf
[
0
:
0
],
in
...
)
...
...
@@ -510,16 +510,43 @@ func doFormBenchmark(b *testing.B, f Form, s string) {
var
ascii
=
strings
.
Repeat
(
"There is nothing to change here! "
,
500
)
func
BenchmarkNormalizeAsciiNFC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFC
,
ascii
)
doFormBenchmark
(
b
,
NFC
,
NFC
,
ascii
)
}
func
BenchmarkNormalizeAsciiNFD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFD
,
ascii
)
doFormBenchmark
(
b
,
NF
C
,
NF
D
,
ascii
)
}
func
BenchmarkNormalizeAsciiNFKC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFKC
,
ascii
)
doFormBenchmark
(
b
,
NF
C
,
NF
KC
,
ascii
)
}
func
BenchmarkNormalizeAsciiNFKD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFKD
,
ascii
)
doFormBenchmark
(
b
,
NFC
,
NFKD
,
ascii
)
}
func
BenchmarkNormalizeNFC2NFC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFC
,
NFC
,
txt_all
)
}
func
BenchmarkNormalizeNFC2NFD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFC
,
NFD
,
txt_all
)
}
func
BenchmarkNormalizeNFD2NFC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFD
,
NFC
,
txt_all
)
}
func
BenchmarkNormalizeNFD2NFD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFD
,
NFD
,
txt_all
)
}
// Hangul is often special-cased, so we test it separately.
func
BenchmarkNormalizeHangulNFC2NFC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFC
,
NFC
,
txt_kr
)
}
func
BenchmarkNormalizeHangulNFC2NFD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFC
,
NFD
,
txt_kr
)
}
func
BenchmarkNormalizeHangulNFD2NFC
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFD
,
NFC
,
txt_kr
)
}
func
BenchmarkNormalizeHangulNFD2NFD
(
b
*
testing
.
B
)
{
doFormBenchmark
(
b
,
NFD
,
NFD
,
txt_kr
)
}
func
doTextBenchmark
(
b
*
testing
.
B
,
s
string
)
{
...
...
@@ -657,3 +684,6 @@ const txt_cn = `您可以自由: 复制、发行、展览、表演、放映、
署名 — 您必须按照作者或者许可人指定的方式对作品进行署名。
相同方式共享 — 如果您改变、转换本作品或者以本作品为基础进行创作,
您只能采用与本协议相同的许可协议发布基于本作品的演绎作品。`
const
txt_cjk
=
txt_cn
+
txt_jp
+
txt_kr
const
txt_all
=
txt_vn
+
twoByteUtf8
+
threeByteUtf8
+
txt_cjk
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment