question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More perf issues with closure classes

See original GitHub issue

Looks like V8 really hates those closure classes. Its taking 36s to generate 100 samples, with most of the time spent in the generate method of:

  noBias(): Arbitrary<T> {
    const arb = this;
    return new class extends Arbitrary<T> {
      generate(mrng: Random): Shrinkable<T> {
        return arb.generate(mrng);
      }
    }();
  }

Should I try to do a PR that removes them all?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:31 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
dubzzzcommented, Oct 29, 2018

I just replayed the tests on my computer by modifying package.json file between each performance test:

  "dependencies": {
    "fast-check": "1.5.0",
    "pure-rand": "1.1.1"
  }

Resulted in:

yarn run v1.10.1
$ tsc && node src/index
perf: 147862.483ms
Asertion count: 20000
Done in 149.53s.

While:

  "dependencies": {
    "fast-check": "1.7.1",
    "pure-rand": "1.5.0"
  }

Resulted in:

yarn run v1.10.1
$ tsc && node src/index
perf: 73844.808ms
Asertion count: 20000
Done in 75.49s.
1reaction
dubzzzcommented, Oct 2, 2018

@spion Next version of fast-check will feature a way to change the random generator by setting the randomType attribute - see #200 - switching to congruential32 might reduce the time taken to generate values.

Meanwhile I am looking for ways to accelerate the generation of values by reducing gc, recompile…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Classes vs. Closures - Performance : r/javascript - Reddit
The real problem I have with inheritance is that it's brittle. It only takes one small, seemingly-insignificant change far up the inheritance ...
Read more >
How to decide between classes v. closures in JavaScript
This tutorial compares the functionality and advantages of classes versus closures in JavaScript to help you determine which is best for ...
Read more >
Reuse Java's closures/anonymous classes for performance?
When I use anonymous classes for small operations like filtering a collection, there is memory allocation for a new anonymous class instance or ......
Read more >
Javascript Classes v. Closures (1/3) | by Richard Marmorstein
Javascript classes and closures are common patterns that can often substitute ... One advantage of the closure pattern is greater lintability.
Read more >
On closures and classes in JavaScript and TypeScript | dragly
If all your functions are made to expect arguments that are interfaces and not specific classes or function signatures, then there is no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found