Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript fannkuch-redux implementation skews results in paper #34

Open
akx opened this issue May 25, 2022 · 1 comment
Open

TypeScript fannkuch-redux implementation skews results in paper #34

akx opened this issue May 25, 2022 · 1 comment

Comments

@akx
Copy link

akx commented May 25, 2022

This is tangentially related to #3.

The 2017 paper (linked today in an article in Finland's largest newspaper about the energy efficiency of IT) implies that TypeScript is about 16 times less energy-efficient with the fannkuch-redux benchmark.
It seems that this is down to the fact that the TypeScript implementation of the program itself is inefficient.

Running hyperfine against the transpiled JavaScript for the TypeScript program (which, naturally, is just JavaScript, so should exactly match the performance of JavaScript), shows this:

$ hyperfine "node TypeScript/fannkuch-redux/fannkuchredux.js 11" "node JavaScript/fannkuch-redux/fannkuchredux.node-4.js 11"
Benchmark 1: node TypeScript/fannkuch-redux/fannkuchredux.js 11
  Time (mean ± σ):      4.518 s ±  0.079 s    [User: 4.490 s, System: 0.016 s]
  Range (min … max):    4.409 s …  4.630 s    10 runs

Benchmark 2: node JavaScript/fannkuch-redux/fannkuchredux.node-4.js 11
  Time (mean ± σ):      2.516 s ±  0.031 s    [User: 2.497 s, System: 0.012 s]
  Range (min … max):    2.454 s …  2.559 s    10 runs

Summary
  'node JavaScript/fannkuch-redux/fannkuchredux.node-4.js 11' ran
    1.80 ± 0.04 times faster than 'node TypeScript/fannkuch-redux/fannkuchredux.js 11'

(I ran these with parameter 11 because I didn't have the patience to wait for Hyperfine to finish all trials at parameter 12 as used in the scripts in the repository, but it seems the performance gap between the programs grows more and more.)

@igouy
Copy link

igouy commented Aug 30, 2022

If you look at the fannkuch-redux, it seems to be a console.log within the loop in the typescript version, which isn't in the JS version.

        while (go) {
            if (r == n) {
                console.log(checksum);
                return flips;
            }

Here's what that console.log outputs:

3968050

Once.

Now look at all the other program differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants