Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Log simple performance data from expect rule #227

Merged
merged 3 commits into from
Apr 11, 2019

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Apr 10, 2019

Write the data to a file with the same name in ~/.dts/perf/some-package-name.json. Consumers can then read the file and display information from there. Note that tslint rules are not expected to write files, so perhaps there's a better way to log this information.

types-publisher and dtslint-runner need to be updated to display the data. Here's a simple script that runs on the output of dtslint-runner:

const fs = require('fs');
const stats = require('stats-lite');
/** @type {Array<[string, number, number]>} */
let big = []
let types = []
for (const filename of fs.readdirSync('~/.dts/perf/', { encoding: "utf8" })) {
    /** @type {{ [s: string]: { typeCount: number, memory: number } }} */
    const x = JSON.parse(fs.readFileSync('~/.dts/perf/' + filename, { encoding: 'utf8' }))
    for (const k of Object.keys(x)) {
        big.push([k, x[k].typeCount])
        types.push(x[k].typeCount)
    }
}
console.log("{" + big.sort((a, b) => b[1] - a[1]).map(([name, count]) => ` "${name}": ${count}`).join(",") + "}")

console.log("99", stats.percentile(types, .99))
console.log("95", stats.percentile(types, .95))
console.log("90", stats.percentile(types, .90))
console.log("70", stats.percentile(types, .70))
console.log("50", stats.percentile(types, .50))

dtslint-runner can print this out or push the json to some data store. types-publisher needs an even smaller change in test-runner to look up and print the json files for each entry in changedPackages so that it shows up in the build output.

1. This is not the right thing for a tslint rule to do.
2. The log isn't written to a very good place.

I think (1) is unavoidable; (2) should be fixed before shipping this
change.
Instead, consumers should read the output files and print results
themselves.
@sandersn sandersn requested a review from andrewbranch April 11, 2019 16:00
Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@sandersn sandersn merged commit e2fbd6d into master Apr 11, 2019
@sandersn sandersn deleted the add-perf-logging-to-expect-rule branch April 11, 2019 17:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants