Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iprep
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai3
tools
iprep
Commits
87570256
Commit
87570256
authored
4 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Batch inserts in benchmarks
parent
e5901c6d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
db/db_test.go
+10
-7
10 additions, 7 deletions
db/db_test.go
with
10 additions
and
7 deletions
db/db_test.go
+
10
−
7
View file @
87570256
...
...
@@ -19,6 +19,9 @@ const (
// How many events to fill up the db, test/bench cases.
manyEventsTest
=
100000
manyEventsBench
=
1000000
// When writing events to the db, do it in batches of this size.
writeBatchSize
=
1000
)
func
randomIP
()
string
{
...
...
@@ -151,10 +154,9 @@ func runWriteBench(b *testing.B, driver string) {
}
defer
db
.
Close
()
// Chunks of 100.
chunkSize
:=
1000
nchunks
:=
b
.
N
/
chunkSize
events
:=
randomEvents
(
chunkSize
)
// Write events in chunks.
nchunks
:=
b
.
N
/
writeBatchSize
events
:=
randomEvents
(
writeBatchSize
)
b
.
ResetTimer
()
...
...
@@ -188,9 +190,10 @@ func runReadBenchmark(b *testing.B, driver string, eventsPerIP int, threadCounts
// Write a lot of events just to bulk up the database, but
// also write a couple of records for a known IP, that we're
// going to read in the benchmark.
n
:=
manyEventsBench
db
.
AddAggregate
(
randomEvents
(
n
))
// going to read in the benchmark. Do it in batches.
for
i
:=
0
;
i
<
manyEventsBench
;
i
+=
writeBatchSize
{
db
.
AddAggregate
(
randomEvents
(
writeBatchSize
))
}
// For a bunch of random IPs, add a known (possibly large)
// number of events.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment