Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

benchmarks #488

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ node_modules

lib
dist

current.json
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ build
node_modules

test

current.json
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"release": "gulp release",
"release-minor": "gulp release --type minor",
"release-major": "gulp release --type major",
"coverage-publish": "aegir-coverage publish"
"coverage-publish": "aegir-coverage publish",
"bench": "./scripts/bench.sh"
},
"pre-commit": [
"lint",
Expand Down
10 changes: 10 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Scripts

## `bench.sh`

Run benchmarks using [ipfs-whatever](https://github.com/whyrusleeping/ipfs-whatever). This will create a file called `current.json` in the current folder with the results.

### Requirements

- go
- Node.js
16 changes: 16 additions & 0 deletions scripts/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

echo "-- downloading benchmarks"
go get github.com/whyrusleeping/ipfs-whatever

echo "-- setting up ipfs"
export IPFS_PATH=/tmp/bench-repo
node src/cli/bin.js init
node src/cli/bin.js daemon &
sleep 5

echo "-- running benchmarks"
ipfs-whatever > current.json

echo "-- cleaning up"
rm -rf /tmp/bench-repo
7 changes: 6 additions & 1 deletion src/http-api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ exports.parseKey = (request, reply) => {
}).code(400).takeover()
}

let arg = request.query.arg
try {
if (arg.indexOf('/ipfs/') === 0) {
arg = arg.replace('/ipfs/', '')
}

return reply({
key: mh.fromB58String(request.query.arg)
key: mh.fromB58String(arg)
})
} catch (err) {
log.error(err)
Expand Down