Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

run benchmark at cursor (#972)#1303

Merged
ramya-rao-a merged 6 commits intomicrosoft:masterfrom
buyology:run-benchmark
Nov 9, 2017
Merged

run benchmark at cursor (#972)#1303
ramya-rao-a merged 6 commits intomicrosoft:masterfrom
buyology:run-benchmark

Conversation

@buyology
Copy link
Copy Markdown
Contributor

this is a stab at #972 along the lines of the discussion to have run benchmark available at the cursor level

note:

  • runs with the -benchmem flag by default
  • use -run=^$ to exclude all tests from being run

look and feel

run-benchmark

(nb: this is my first foray into typescript, and my first locs in javascript in many years so please bear with me)

cc @scriptnull @ironcladlou @campoy @rakyll

@msftclas
Copy link
Copy Markdown

msftclas commented Oct 25, 2017

CLA assistant check
All CLA requirements met.

@ramya-rao-a ramya-rao-a force-pushed the master branch 3 times, most recently from 89e20b7 to 3d8a1f0 Compare November 4, 2017 19:44
Copy link
Copy Markdown
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

@buyology Thanks for your patience, it took me a while to get to the PRs this last month.

Good start, I have left a few comments, mainly around refactoring some code. Please do take a look

src/testUtils.ts Outdated
function targetArgs(testconfig: TestConfig): Thenable<Array<string>> {
function testTargetArgs(testconfig: TestConfig): Thenable<Array<string>> {
if (testconfig.functions) {
return Promise.resolve(['-run', util.format('^%s$', testconfig.functions.join('|'))]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of having a separate benchmarkTargetArgs, you can just use -bench here instead of -run if testconfig.isBenchmark is true

src/testUtils.ts Outdated
* @return whether the name has a test function prefix.
*/
function hasTestFunctionPrefix(name: string): boolean {
export function hasTestFunctionPrefix(name: string): boolean {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There was no real point of making this a separate function in the first place (my apologies).

Instead of exporting this prefix function and adding another for benchmark, we can simplify things as below

  • remove hasTestFunctionPrefix and move the prefix check into getTestFunctions
  • create and export a new function getBenchmarkFunctions which will have the same code as getTestFunctions but with a different prefix check.

It will definitely get simpler when importing these functions in other files


});

return Promise.resolve(codelens);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This Promise should resolve only after both tests and benchmark functions are found

@ramya-rao-a ramya-rao-a merged commit abcd89a into microsoft:master Nov 9, 2017
@ramya-rao-a
Copy link
Copy Markdown
Contributor

@buyology I went ahead and made the refactorings myself, hope you dont mind.
Great work!

@buyology
Copy link
Copy Markdown
Contributor Author

buyology commented Nov 9, 2017

@ramya-rao-a did not mind :) thanks!

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.

3 participants