Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(models): adds benchmark model generator #89

Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9424a81
feat(models): adds benchmark model generator
Jan 31, 2024
b079930
feat(models): move benchmark model generator code
Feb 1, 2024
cf88979
feat(models): minor tweaks
Feb 1, 2024
a7f13db
test(models): adds unit tests
Feb 1, 2024
b61aa59
feat(models): have Blob imported for Node.js v16 compitability
Feb 1, 2024
40c2bc3
fix(models): adds buffer dependency needed for Node.js v16
Feb 1, 2024
fd46196
docs(models generation): adds readme
Feb 1, 2024
1c9b50b
fix(models): polyfill buffer
Feb 1, 2024
33a58e7
refactor(models): more generic generated model namespace
Feb 1, 2024
c39e8de
fix(models): changed model generated class to public by JSDoc
Feb 1, 2024
ecdbf8b
test(models): amend generated models' stats
Feb 1, 2024
2dabc92
fix(models): remove external dependency for name generation
Feb 1, 2024
d01408f
feat(models): adds a heap size check
Feb 1, 2024
99f0c0f
fix(models): optimised model generation
Feb 1, 2024
60199ab
fix(models): added type defs
Feb 1, 2024
7a0ca0b
fix(deps): adds v8 polyfill
Feb 1, 2024
204d0ed
feat(deps): trying to polyfill v8
Feb 1, 2024
f5b02eb
feat(models): heap size performance optimization
Feb 1, 2024
e013197
fix(models): assign class method accessibility
Feb 1, 2024
9b8838d
fix(models): generated model size is compared against total_available…
Feb 1, 2024
7036044
refactor(models): improve error wording
Feb 1, 2024
3edb8e2
fix(deps): adds node polyfill
Feb 1, 2024
02e2088
fix(deps): renamed v8 addressed without node:
Feb 1, 2024
2ea743f
fix(models): limit generated model to a 100 MiB
Feb 1, 2024
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
36 changes: 16 additions & 20 deletions lib/common/benchmarkModelGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,16 @@ class BenchmarkModelGenerator {
let propertyI = 0;

while (!oversized) {
const propertiesWithNewAddition = [
...properties,
this.generateProperty({
modelI,
declarationI,
propertyI,
})
];
const generatedProperty = this.generateProperty({
modelI,
declarationI,
propertyI,
});

if (this.jsonSize(propertiesWithNewAddition) <= propertiesSizeBudget) {
propertiesSizeBudget = propertiesSizeBudget - this.jsonSize(generatedProperty);
if (propertiesSizeBudget >= 0) {
propertyI++;
properties = propertiesWithNewAddition;
properties = [ ...properties, generatedProperty ];
mttrbrts marked this conversation as resolved.
Show resolved Hide resolved
} else {
oversized = true;
}
Expand Down Expand Up @@ -227,18 +225,16 @@ class BenchmarkModelGenerator {
let declarationI = 0;

while (!oversized) {
const declarationsWithNewAddition = [
...declarations,
this.generateDeclarationWithNProperties({
modelI,
declarationI,
nProperties,
})
];
const generatedDeclaration = this.generateDeclarationWithNProperties({
modelI,
declarationI,
nProperties,
});

if (this.jsonSize(declarationsWithNewAddition) <= declarationsSizeBudget) {
declarationsSizeBudget = declarationsSizeBudget - this.jsonSize(generatedDeclaration);
if (declarationsSizeBudget >= 0) {
declarationI++;
declarations = declarationsWithNewAddition;
declarations = [...declarations, generatedDeclaration];
} else {
oversized = true;
}
Expand Down
Loading