1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-25 02:04:15 +02:00

adding performance benchmark

This commit is contained in:
Patrik J. Braun 2019-01-26 18:28:04 -05:00
parent 0445c499e8
commit 0748a3ed5b
3 changed files with 31 additions and 7 deletions

View File

@ -84,18 +84,18 @@ export class Benchmarks {
const startSkip = process.hrtime();
await beforeEach();
const endSkip = process.hrtime(startSkip);
skip += (endSkip[0] * 1000 + endSkip[1] / 1000);
skip += (endSkip[0] * 1000 + endSkip[1] / 1000000);
}
await fn();
if (afterEach) {
const startSkip = process.hrtime();
await afterEach();
const endSkip = process.hrtime(startSkip);
skip += (endSkip[0] * 1000 + endSkip[1] / 1000);
skip += (endSkip[0] * 1000 + endSkip[1] / 1000000);
}
}
const end = process.hrtime(start);
const duration = (end[0] * 1000 + end[1] / 1000) / this.RUNS;
const duration = (end[0] * 1000 + end[1] / 1000000) / this.RUNS;
if (!scanned) {
return {

View File

@ -2,4 +2,21 @@
These results are created mostly for development, but I'm making them public for curious users.
## PiGallery2 v1.5.8, 06.01.2019
**System**: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz, 16GB Ram, SHDD: 1TB, 5400 rpm
**Gallery**: directories: 0 media: 341, faces: 39
| action | action details | average time | details |
|:------:|:--------------:|:------------:|:-------:|
| Scanning directory | | 2486.5ms | media: 341, directories:0 |
| Saving directory | | 780.0ms | - |
| Listing Directory | | 31.5ms | media: 341, directories:0 |
| searching | `a` as `directory` | 2.9ms | - |
| searching | `a` as `person` | 7.3ms | media: 39, directories:0 |
| searching | `a` as `keyword` | 30.8ms | media: 339, directories:0 |
| searching | `a` as `position` | 25.7ms | media: 282, directories:0 |
| searching | `a` as `photo` | 2.8ms | - |
| searching | `a` as `video` | 2.6ms | - |
| searching | `a` as `any` | 33.0ms | media: 339, directories:0 |
| instant search | `a` | 6.1ms | media: 10, directories:0 |
| auto complete | `a` | 5.4ms | items: 10 |

View File

@ -10,7 +10,7 @@ const config: { path: string, system: string } = require(path.join(__dirname, 'c
Config.Server.imagesFolder = config.path;
const dbPath = path.join(__dirname, 'test.db');
ProjectPath.reset();
const RUNS = 1;
const RUNS = 50;
let resultsText = '';
const printLine = (text: string) => {
@ -25,7 +25,11 @@ const printHeader = async () => {
'.' + dt.getFullYear());
printLine('**System**: ' + config.system);
const dir = await DiskMangerWorker.scanDirectory('./');
printLine('**Gallery**: directories:' + dir.directories.length + ' media:' + dir.media.length);
printLine('**Gallery**: directories: ' +
dir.directories.length +
' media: ' + dir.media.length +
// @ts-ignore
', faces: ' + dir.media.reduce((p, c) => p + (c.metadata.faces || []).length, 0));
};
@ -34,6 +38,7 @@ const printTableHeader = () => {
printLine('|:------:|:--------------:|:------------:|:-------:|');
};
const printResult = (result: BenchmarkResult, action: string, actionDetails: string = '') => {
console.log('benchmarked: ' + action);
let details = '-';
if (result.items) {
details = 'items: ' + result.items;
@ -42,10 +47,11 @@ const printResult = (result: BenchmarkResult, action: string, actionDetails: str
details = 'media: ' + result.media + ', directories:' + result.directories;
}
printLine('| ' + action + ' | ' + actionDetails +
' | ' + (result.duration / 1000).toFixed(2) + 's | ' + details + ' |');
' | ' + (result.duration).toFixed(1) + 'ms | ' + details + ' |');
};
const run = async () => {
const start = Date.now();
const bm = new Benchmarks(RUNS, dbPath);
// header
@ -64,6 +70,7 @@ const run = async () => {
printResult(await bm.bmInstantSearch('a'), 'instant search', '`a`');
printResult(await bm.bmAutocomplete('a'), 'auto complete', '`a`');
console.log(resultsText);
console.log('run for : ' + ((Date.now() - start)).toFixed(1) + 'ms');
};
run();