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
481e619c
Commit
481e619c
authored
Sep 23, 2011
by
Eric Eisner
Committed by
Robert Griesemer
Sep 23, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
suffixarray: add benchmarks for construction
R=gri, jeff CC=golang-dev
https://golang.org/cl/5040048
parent
17410d75
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
src/pkg/index/suffixarray/suffixarray_test.go
src/pkg/index/suffixarray/suffixarray_test.go
+24
-0
No files found.
src/pkg/index/suffixarray/suffixarray_test.go
View file @
481e619c
...
...
@@ -257,6 +257,30 @@ func TestIndex(t *testing.T) {
}
}
// Of all possible inputs, the random bytes have the least amount of substring
// repetition, and the repeated bytes have the most. For most algorithms,
// the running time of every input will be between these two.
func
benchmarkNew
(
b
*
testing
.
B
,
random
bool
)
{
b
.
StopTimer
()
data
:=
make
([]
byte
,
1e6
)
if
random
{
for
i
:=
range
data
{
data
[
i
]
=
byte
(
rand
.
Intn
(
256
))
}
}
b
.
StartTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
New
(
data
)
}
}
func
BenchmarkNewIndexRandom
(
b
*
testing
.
B
)
{
benchmarkNew
(
b
,
true
)
}
func
BenchmarkNewIndexRepeat
(
b
*
testing
.
B
)
{
benchmarkNew
(
b
,
false
)
}
func
BenchmarkSaveRestore
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
r
:=
rand
.
New
(
rand
.
NewSource
(
0x5a77a1
))
// guarantee always same sequence
...
...
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