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

sunspider/date-format-tofte not working #112

Open
maximecb opened this issue May 25, 2014 · 3 comments
Open

sunspider/date-format-tofte not working #112

maximecb opened this issue May 25, 2014 · 3 comments
Labels

Comments

@maximecb
Copy link
Contributor

The sunspider/date-format-tofte benchmark seems to be using very high amounts of memory, possibly due to string allocation. I stopped it after it had expanded the Higgs heap to 4GB on my system, which seems completely abnormal (these benchmarks are meant to run in a browser, on a computer from 1999).

@maximecb maximecb added the bug label May 25, 2014
@bFraley
Copy link
Contributor

bFraley commented Jun 20, 2014

I think there's a hiccup either right at the beginning of the file, the arrayExists loop, or near the end using keyword 'while'.

Does arrayExists ever return false ?
Lines 1 - 8

 function arrayExists(array, x) {
  /* BEGIN LOOP */
    for (var i = 0; i < array.length; i++) {
        if (array[i] == x) return true;
    }
  /* END LOOP */
    return false;
}

This is some cryptic hackmanship here. Uses while and uses arrayExists(switches,ia[ij]))
as an arg to a nested if. Again, does arrayExists ever return false ?

Additionally is: eval(ia[ij] + "()"

Lines: 274 - 294

    var ia = input.split("");
    var ij = 0;
  /* BEGIN LOOP */
    while (ia[ij]) {
        if (ia[ij] == "\\") {
            // this is our way of allowing users to escape stuff
            ia.splice(ij,1);
        } else {
            if (arrayExists(switches,ia[ij])) {
                ia[ij] = eval(ia[ij] + "()");
            }
        }
        ij++;
    }
  /* END LOOP */
    // reset time, back to what it was
    if (prevTime) {
        self.setTime(prevTime);
    }
    return ia.join("");
}    

@maximecb
Copy link
Contributor Author

The problem might just be the eval. It doesn't support capturing local variables at the moment.

@mollymorphic
Copy link
Contributor

Note that PR #125 fixes the memory consumption issue. The benchmark still fails however due to the fact that it relies on eval'd code being able to access the current scope.

@maximecb maximecb changed the title sunspider/date-format-tofte bug sunspider/date-format-tofte not working Oct 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants