-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor HTTP server and add mote tests
- Add health route - Handle server close gracefully - Add new methods to storage getMaxStorageSize and getDefaultTTL - Add tests got HTTP server - Add more API tests - Improve test tools - Run tests in one thread - Add placeholder for performance tests - Update express
- Loading branch information
Showing
13 changed files
with
360 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ jobs: | |
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm ci | ||
- run: npm run test | ||
- run: npm run test:coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import KVStore from '../src/kvStore'; | ||
|
||
function getPercentile(latencyArr: number[], percentile: number) { | ||
latencyArr.sort((a, b) => a - b); | ||
const index = Math.ceil((percentile / 100) * latencyArr.length) - 1; | ||
return latencyArr[index]; | ||
} | ||
|
||
describe('Storage performance', () => { | ||
test.skip('Add 1M items', async () => { | ||
const store = new KVStore(1000000); | ||
|
||
console.log(`>>> memory usage`, process.memoryUsage()); | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
store.set(i, { someData: 'test data' }); | ||
} | ||
|
||
console.log(`>>> memory usage`, process.memoryUsage()); | ||
|
||
const latency: number[] = []; | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
const start = performance.now(); | ||
store.set(i, { someData: 'test data' }); | ||
const end = performance.now(); | ||
|
||
latency.push(Math.ceil(end - start)); | ||
} | ||
|
||
console.log(`>>> memory usage`, process.memoryUsage()); | ||
|
||
const p90 = getPercentile(latency, 90); | ||
console.log(`90th percentile: ${p90} ms`); | ||
const p95 = getPercentile(latency, 95); | ||
console.log(`95th percentile: ${p95} ms`); | ||
const p99 = getPercentile(latency, 99); | ||
console.log(`99th percentile: ${p99} ms`); | ||
}); | ||
|
||
test.skip('Get 1M items', async () => { | ||
const store = new KVStore(1000000); | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
store.set(i, { someData: 'test data' }); | ||
} | ||
|
||
const latency: number[] = []; | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
const start = performance.now(); | ||
store.get(i); | ||
const end = performance.now(); | ||
|
||
latency.push(Math.ceil(end - start)); | ||
} | ||
|
||
const p90 = getPercentile(latency, 90); | ||
console.log(`90th percentile: ${p90} ms`); | ||
const p95 = getPercentile(latency, 95); | ||
console.log(`95th percentile: ${p95} ms`); | ||
const p99 = getPercentile(latency, 99); | ||
console.log(`99th percentile: ${p99} ms`); | ||
}); | ||
}); |
Oops, something went wrong.