-
Notifications
You must be signed in to change notification settings - Fork 6
/
benchmark.js
31 lines (23 loc) · 1.19 KB
/
benchmark.js
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
const execa = require('execa');
async function benchmark(desc, command, before, after) {
console.log(desc);
if(before && before.length){
execa.commandSync(before, {shell: true})
}
var start = new Date
const {stdout} = execa.commandSync(command, {shell: true});
var end = new Date
if(after && after.length){
execa.commandSync(after, {shell: true})
}
console.log(' -', end - start, 'ms')
}
(async () => {
execa.commandSync('cp test/fixtures/go.mod go.mod', {shell: true})
await benchmark('proxy.golang.org, no cache', 'go get github.com/ipfs/go-ipfs-ds-help', 'go clean --modcache')
await benchmark('proxy.golang.org, cache', 'go get github.com/ipfs/go-ipfs-ds-help')
await benchmark('forage go, no go cache, no forage cache', 'GOPROXY=http://localhost:8005 go get github.com/ipfs/go-ipfs-ds-help', 'forage reset && go clean --modcache')
await benchmark('forage go, no go cache, forage cache', 'GOPROXY=http://localhost:8005 go get github.com/ipfs/go-ipfs-ds-help', 'go clean --modcache')
await benchmark('forage go, go cache, forage cache', 'GOPROXY=http://localhost:8005 go get github.com/ipfs/go-ipfs-ds-help')
execa.commandSync('rm go.mod go.sum', {shell: true})
})();