音乐会代码Gen
用于 音乐会 格式化模型文件.
安装
npm install @accordproject/concerto-codegen --save
使用
基准模型生成器
此 API 允许您生成不同大小的模型( 最多 100 MiB) , 用于测试您的 Concerto 处理代码的性能 .
生成一个最多为指定数量的声明和属性的模型
您可以使用 :
const benchmarkModelGenerator = new BenchmarkModelGenerator();
const generated = benchmarkModelGenerator.generateConcertoModels({
nDeclarations: 5, // Number of declarations in the model
nProperties: 5, // Number of properties per declaration
});
在字节中生成一个最大为指定大小的模型
您可以在字节中生成一个最大为指定大小的模型, 但是您需要指定该模型应该如何生长 .
按申报数量增加模式
如果您想要按照声明的数量增加, 您需要指定您希望模型拥有的属性数量( 默认为 1:
const benchmarkModelGenerator = new BenchmarkModelGenerator();
const generated = benchmarkModelGenerator.generateConcertoModels({
generateUpToSize: 10000, // Target upper limit of growth in bytes
growBy: 'declarations', // Element type by which the model should grow
nProperties: 5, // Number of properties per declaration
});
按属性数增长模型
如果您想要按照属性的数量来增长, 您需要指定您希望模型声明的数量( 默认为 1:
const benchmarkModelGenerator = new BenchmarkModelGenerator();
const generated = benchmarkModelGenerator.generateConcertoModels({
generateUpToSize: 10000, // Target upper limit of growth in bytes
growBy: 'properties', // Element type by which the model should grow
nProperties: 5, // Number of declarations in the model
});
预期反应将包括生成的一系列 models (目前只包含单一模型)和 metadata 含有生成模型信息的对象,例如:
{
models: [
{
'$class': '[email protected]',
decorators: [],
namespace: '[email protected]',
imports: [],
declarations: [
...
]
}
],
metadata: {
requestedModelSizeInBytes: 10000,
humanReadableRequestedModelSize: '9.77 KiB',
generatedModelSizeInBytes: 9952,
humanReadableGeneratedModelSize: '9.72 KiB',
declarationsN: 5,
propertiesNInSmallestDeclaration: 15,
propertiesNInLargestDeclaration: 16
}
}
正如您从上面的例子模型中看到的, 生成器将尽力到达顶端 generateUpToSize 请求的大小,但可能不足几个字节.
许可证
Accord Project源代码文件在位于LICENSE文件的Apache许可证2.0版本(Apache-2.0)下提供. 项目文件文件根据创用CC-BY-4.0国际许可证提供 http://creativecommons.org/licenses/by/ 4.0/ 页面存档备份,存于互联网档案馆。 。 。 .