-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathJenkinsfile.benchmark
79 lines (68 loc) · 2.55 KB
/
Jenkinsfile.benchmark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/env groovy
@Library('[email protected]') _
properties([
parameters([
string(name: 'CONFIG', defaultValue: 'ci/browser.js'),
]),
])
def setGithubCommitStatus(commit, status, message) {
withCredentials([[
$class: 'StringBinding',
credentialsId: '5d3e0a3c-2490-491b-8a67-aa5eab2f27f2',
variable: 'GITHUB_TOKEN'
]]) {
github.setCommitStatus(
env.GITHUB_TOKEN,
'cliqz/navigation-extension',
commit,
'Benchmark',
status,
message
)
}
}
String triggeringCommitHash = github.getCommitHash()
node('docker && !gpu && us-east-1') {
def imgName = "cliqz/navigation-extension-benchmark"
def image
stage('checkout') {
setGithubCommitStatus(triggeringCommitHash, 'pending', 'pending')
checkout scm
}
stage('docker build') {
image = docker.build(imgName, '-f Dockerfile.benchmark .')
}
image.inside() {
withEnv(["CLIQZ_CONFIG_PATH=./configs/${params.CONFIG}"]) {
stage('fern build') {
sh 'cp -r /app/node_modules ./'
sh 'cp -r /app/benchmarks/node_modules ./benchmarks/'
sh './fern.js build'
}
stage('benchmark') {
sh 'cp /app/benchmarks/session.jl ./benchmarks/'
sh 'cp /app/benchmarks/requests.jl ./benchmarks/'
try {
dir('./benchmarks') {
sh 'node run_benchmarks.js > results.txt'
sh 'cat results.txt'
}
// read cputime results
def cputime = sh(returnStdout: true, script: 'cat ./benchmarks/results.txt | grep -v \'=\' | jq .cputime | awk \'{ sum+=$1 } END { print sum }\'')
def memory = sh(returnStdout: true, script: 'cat ./benchmarks/results.txt | grep -v \'=\' | jq .memory | awk \'{ sum+=$1 } END { print sum }\'')
def summary = "CPU Time: ${(cputime as Double).round(2)}, Memory: ${((memory as Integer) / (5 * 1024 * 1024)) as Integer}MB"
currentBuild.description = summary
sh 'du -hs ./benchmarks/data/idb/*'
setGithubCommitStatus(triggeringCommitHash, 'success', summary)
sh "cat ./benchmarks/results.txt | node ./benchmarks/post_results.js ${triggeringCommitHash}"
// print diagnostics
sh 'cat ./benchmarks/diagnostics.jl | jq .'
sh 'rm -r ./benchmarks/data ./benchmarks/diagnostics.jl'
} catch (e) {
currentBuild.result = 'FAILURE'
setGithubCommitStatus(triggeringCommitHash, 'failure', 'Benchmark failed')
}
}
}
}
}