How to use the faastjs.CostAnalyzer.analyze function in faastjs

To help you get started, we’ve selected a few faastjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github faastjs / examples / aws-cost-analyzer-ts / index.ts View on Github external
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'.`);
}
github faastjs / examples / aws-cost-analyzer-js / index.js View on Github external
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'.`);
github faastjs / faast.js / examples / cost-analyzer-aws-bandwidth.ts View on Github external
async function compareAws(Bucket: string, filter: FilterFn) {
    const result = await CostAnalyzer.analyze({
        funcs,
        work: workload(Bucket, filter),
        format,
        formatCSV,
        repetitions: 5,
        concurrency: 5
    });
    writeFile("cost.csv", result.csv());
}
github faastjs / examples / cost-analyzer-comparison-ts / index.ts View on Github external
async function compareCloudCosts() {
    const result = await CostAnalyzer.analyze({ funcs, work, configurations });

    await writeFile("cost.csv", result.csv());
}