Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2a4fb537
Commit
2a4fb537
authored
Jul 24, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test report for performance_test.go
parent
cb7f2d58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
internal/lsif_transformer/parser/performance_test.go
internal/lsif_transformer/parser/performance_test.go
+14
-15
No files found.
internal/lsif_transformer/parser/performance_test.go
View file @
2a4fb537
package
parser
import
(
"fmt"
"os"
"runtime"
"testing"
...
...
@@ -14,23 +13,22 @@ func BenchmarkGenerate(b *testing.B) {
tmpDir
:=
filePath
+
".tmp"
defer
os
.
RemoveAll
(
tmpDir
)
m
:=
measureMemory
(
func
()
{
file
,
err
:=
os
.
Open
(
filePath
)
require
.
NoError
(
b
,
err
)
var
memoryUsage
float64
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
memoryUsage
+=
measureMemory
(
func
()
{
file
,
err
:=
os
.
Open
(
filePath
)
require
.
NoError
(
b
,
err
)
p
,
err
:=
NewParser
(
file
,
Config
{
ProcessReferences
:
true
})
require
.
NoError
(
b
,
err
)
p
,
err
:=
NewParser
(
file
,
Config
{
ProcessReferences
:
true
})
require
.
NoError
(
b
,
err
)
_
,
err
=
p
.
ZipReader
()
require
.
NoError
(
b
,
err
)
require
.
NoError
(
b
,
p
.
Close
())
})
_
,
err
=
p
.
ZipReader
()
require
.
NoError
(
b
,
err
)
require
.
NoError
(
b
,
p
.
Close
())
})
}
// Golang 1.13 has `func (*B) ReportMetric`
// It makes sense to replace fmt.Printf with
// b.ReportMetric(m, "MiB/op")
fmt
.
Printf
(
"BenchmarkGenerate: %f MiB/op
\n
"
,
m
)
b
.
ReportMetric
(
memoryUsage
/
float64
(
b
.
N
),
"MiB/op"
)
}
func
measureMemory
(
f
func
())
float64
{
...
...
@@ -40,6 +38,7 @@ func measureMemory(f func()) float64 {
f
()
runtime
.
ReadMemStats
(
&
m1
)
runtime
.
GC
()
return
float64
(
m1
.
Alloc
-
m
.
Alloc
)
/
1024
/
1024
}
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