Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
64f75f10
Commit
64f75f10
authored
Mar 08, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strings: better benchmark names; add BenchmarkIndex
R=dsymonds CC=golang-dev
https://golang.org/cl/4264052
parent
145108ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
strings_test.go
src/pkg/strings/strings_test.go
+17
-5
No files found.
src/pkg/strings/strings_test.go
View file @
64f75f10
...
...
@@ -138,24 +138,36 @@ func TestIndexRune(t *testing.T) {
}
}
const
benchmarkString
=
"some_text=some☺value"
func
BenchmarkIndexRune
(
b
*
testing
.
B
)
{
if
got
:=
IndexRune
(
"some_text=some☺value"
,
'☺'
);
got
!=
14
{
if
got
:=
IndexRune
(
benchmarkString
,
'☺'
);
got
!=
14
{
panic
(
"wrong index: got="
+
strconv
.
Itoa
(
got
))
}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
IndexRune
(
benchmarkString
,
'☺'
)
}
}
func
BenchmarkIndexRuneFastPath
(
b
*
testing
.
B
)
{
if
got
:=
IndexRune
(
benchmarkString
,
'v'
);
got
!=
17
{
panic
(
"wrong index: got="
+
strconv
.
Itoa
(
got
))
}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
IndexRune
(
"some_text=some☺value"
,
'☺
'
)
IndexRune
(
benchmarkString
,
'v
'
)
}
}
func
BenchmarkIndex
Byte
(
b
*
testing
.
B
)
{
if
got
:=
Index
Rune
(
"some_text=some☺value"
,
'v'
);
got
!=
17
{
func
BenchmarkIndex
(
b
*
testing
.
B
)
{
if
got
:=
Index
(
benchmarkString
,
"v"
);
got
!=
17
{
panic
(
"wrong index: got="
+
strconv
.
Itoa
(
got
))
}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
Index
Rune
(
"some_text=some☺value"
,
'v'
)
Index
(
benchmarkString
,
"v"
)
}
}
type
ExplodeTest
struct
{
s
string
n
int
...
...
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