• Thr 2018.08.30

    Am seeking a processor intensive benchmark routine, that I may test the consitency of loop timing.

    Found this snippet in 'C' using square roots, but I've seen, but unable to locate, other more suitable ones.

    https://stackoverflow.com/questions/1861­294/how-to-calculate-execution-time-of-a­-code-snippet-in-c

    Have a working (at least I think I do) timing mechanism, but am open to a standard benchmark routine.

    Ideas anyone?

  • Robin,

    You have posted a series of related posts, and now this one.

    It's quite hard to determine what it is you are trying to achieve - you are asking abstract questions, whereas if you stated what the goal or task is - then suggestions can be made.

    Perhaps if you simply stated the what oh want to archive people can then offer solutions.

  • Fri 2018.08.31

    Thank you @Wilberforce for responding.

    Each post stated a specific objective for each individual task to be accomplished. All smaller parts of a large project. I wasn't expecting anyone to provide the entire project solution coded, just respond to a smaller subset. This should make for easier understanding, and thus provide a speedier response on a lesser demanding concept.

    As you inquired specifically about this one, to quell your thirst to know, a function I created seems to get bogged down on large simultaneous array bit manipulation. Very similar to how bitblt() worked with Windows programming. I miss *pointers

    Tasks seem to execute even after loops time out. I suspect the order of initiating setTimeout() is part of the problem. And/or multiple calls to Math.sin() which would point to interpreter response time. To rule that out, I was seeking a benchmark routine that was processor intensive and had a consistent execution time, such that I could gage if similar sections I had coded seemed reasonable. The output would be similar to how a function profiler would work. Time stamping entry and exit to determine the potential hangup point.

    A sample benchmark from forty years ago was something like

    Math (( F(x) * F(y) ) / F(x)) * (F(y) / ( F(x) * F(y) ))

    executed 1000 times. I just can't locate a reference nor am I able to trigger the recall brain cells into action.

    The sqrt() concept from link in #1 might be fun to convert from 'C' to Javascript, but felt someone might have the solution standard above, should they have been down this path.

    and no, Graphics.createArrayBuffer() is not what I'm after.

  • If you want to control flow in an event model- then chained promises might be what you are after.

    Manipulating bits might be more intensive - if you have the space, use a byte- takes a look at the dataview classes. With these you can operate on a chunk of an existing array.

  • Generally manipulating large arrays of values directly in Espruino isn't going to be very quick, although the notes in http://www.espruino.com/Performance might help you out a bit.

    Since Espruino is single-threaded, it doesn't really matter what you do to use up the time if you want a function that takes a while. Simply doing:

    function wait1sec() {
      var  t = getTime()+1;
      while (getTime()<t);
    }
    

    Would work fine to give you a known delay - however while it's fine for debugging, doing it in any real code is not recommended (See FAQ: Is there a delay function)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Seeking benchmark function snippet for tight loop timing

Posted by Avatar for Robin @Robin

Actions