mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Updating benchmark to contain results size
This commit is contained in:
parent
56b0b38d93
commit
6394eb4f86
@ -153,7 +153,7 @@ export class Benchmark {
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
duration: null,
|
duration: null,
|
||||||
items: output.length,
|
items: output,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ export class Benchmark {
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
duration: null,
|
duration: null,
|
||||||
items: msg.length,
|
items: msg,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ export interface BenchmarkResult {
|
|||||||
experiment?: string;
|
experiment?: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
contentWrapper?: ContentWrapper;
|
contentWrapper?: ContentWrapper;
|
||||||
items?: number;
|
items?: any[];
|
||||||
subBenchmarks?: BenchmarkResult[];
|
subBenchmarks?: BenchmarkResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
export const Experiments = {
|
export const Experiments:
|
||||||
db: {
|
{ [key: string]: { name: string, groups: { [key: string]: string } } } = {
|
||||||
name: 'SQlite',
|
|
||||||
groups: {
|
|
||||||
betterSqlite: 'better-sqlite'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ActiveExperiments: { [key: string]: string } = {};
|
export const ActiveExperiments: { [key: string]: string } = {};
|
||||||
|
@ -3,6 +3,7 @@ import {ProjectPath} from '../src/backend/ProjectPath';
|
|||||||
import {BenchmarkResult, BenchmarkRunner} from './BenchmarkRunner';
|
import {BenchmarkResult, BenchmarkRunner} from './BenchmarkRunner';
|
||||||
import {Utils} from '../src/common/Utils';
|
import {Utils} from '../src/common/Utils';
|
||||||
import {BMConfig} from './BMConfig';
|
import {BMConfig} from './BMConfig';
|
||||||
|
import {DirectoryDTOUtils} from '../src/common/entities/DirectoryDTO';
|
||||||
|
|
||||||
|
|
||||||
Config.Server.Media.folder = BMConfig.path;
|
Config.Server.Media.folder = BMConfig.path;
|
||||||
@ -35,17 +36,31 @@ const printTableHeader = () => {
|
|||||||
};
|
};
|
||||||
const printExperimentResult = (result: BenchmarkResult, isSubResult = false) => {
|
const printExperimentResult = (result: BenchmarkResult, isSubResult = false) => {
|
||||||
console.log('benchmarked: ' + result.name);
|
console.log('benchmarked: ' + result.name);
|
||||||
|
|
||||||
|
const fileSize = (size: number): string => {
|
||||||
|
const postFixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
|
let index = 0;
|
||||||
|
while (size > 1000 && index < postFixes.length - 1) {
|
||||||
|
size /= 1000;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return size.toFixed(2) + postFixes[index];
|
||||||
|
};
|
||||||
let details = '-';
|
let details = '-';
|
||||||
if (result.items) {
|
if (result.items) {
|
||||||
details = 'items: ' + result.items;
|
details = 'items: ' + result.items.length +
|
||||||
|
', size: ' + fileSize(JSON.stringify(result.items).length);
|
||||||
}
|
}
|
||||||
if (result.contentWrapper) {
|
if (result.contentWrapper) {
|
||||||
if (result.contentWrapper.directory) {
|
if (result.contentWrapper.directory) {
|
||||||
details = 'media: ' + result.contentWrapper.directory.media.length +
|
details = 'media: ' + result.contentWrapper.directory.media.length +
|
||||||
', directories: ' + result.contentWrapper.directory.directories.length;
|
', directories: ' + result.contentWrapper.directory.directories.length +
|
||||||
|
', size: ' + fileSize(JSON.stringify(DirectoryDTOUtils.packDirectory(result.contentWrapper.directory)).length);
|
||||||
} else {
|
} else {
|
||||||
details = 'media: ' + result.contentWrapper.searchResult.media.length +
|
details = 'media: ' + result.contentWrapper.searchResult.media.length +
|
||||||
', directories: ' + result.contentWrapper.searchResult.directories.length;
|
', directories: ' + result.contentWrapper.searchResult.directories.length +
|
||||||
|
', size: ' + fileSize(JSON.stringify(result.contentWrapper.searchResult).length);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isSubResult) {
|
if (isSubResult) {
|
||||||
|
@ -29,7 +29,7 @@ export const ServerTime = (id: string, name: string) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const m = descriptor.value;
|
const m = descriptor.value;
|
||||||
descriptor.value = (req: Request, res: Response, next: NextFunction) => {
|
const customAction = (req: Request, res: Response, next: NextFunction) => {
|
||||||
req.timing = req.timing || {};
|
req.timing = req.timing || {};
|
||||||
req.timing[id] = new ServerTimeEntry(name);
|
req.timing[id] = new ServerTimeEntry(name);
|
||||||
req.timing[id].start();
|
req.timing[id].start();
|
||||||
@ -38,6 +38,8 @@ export const ServerTime = (id: string, name: string) => {
|
|||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
descriptor.value = new Function('action', 'return function ' + m.name + '(...args){ action(...args) };')(customAction);
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user