Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
const result = await CostAnalyzer.analyze({
funcs,
work: async m => {
const promises = [];
for (let i = 0; i < 10; i++) {
promises.push(m.functions.random(100000));
}
await Promise.all(promises);
},
configurations: CostAnalyzer.awsConfigurations.filter(
c => c.options.memorySize! >= 1024 && c.options.memorySize! <= 2048
)
});
writeFileSync("cost.csv", result.csv());
console.log(`Wrote 'cost.csv'.`);
}
async function main() {
const result = await CostAnalyzer.analyze(
{
funcs,
work: async m => {
const promises = [];
for (let i = 0; i < 10; i++) {
promises.push(m.functions.random(100000));
}
await Promise.all(promises);
}
},
CostAnalyzer.awsConfigurations.filter(
c => c.options.memorySize >= 1024 && c.options.memorySize <= 2048
)
);
writeFileSync("cost.csv", result.csv());
console.log(`Wrote 'cost.csv'.`);
}
import { CostAnalyzer, FaastModule } from "faastjs";
import * as funcs from "./functions";
import { writeFile as fsWriteFile } from "fs";
import { promisify } from "util";
const writeFile = promisify(fsWriteFile);
async function work(faastModule: FaastModule) {
await faastModule.functions.random(1000000);
}
const memorySizes = [128, 256, 512, 1024, 1728, 2048];
const configurations = [
...CostAnalyzer.awsConfigurations.filter(c =>
memorySizes.find(m => m === c.options.memorySize!)
),
...CostAnalyzer.googleConfigurations.filter(c =>
memorySizes.find(m => m === c.options.memorySize!)
)
];
async function compareCloudCosts() {
const result = await CostAnalyzer.analyze({ funcs, work, configurations });
await writeFile("cost.csv", result.csv());
}
compareCloudCosts();