Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Simple date and time manipulation

by sundialsvc4 (Abbot)
on Jan 19, 2011 at 13:17 UTC ( #883114=note: print w/replies, xml ) Need Help??


in reply to Simple date and time manipulation

I would cordially argue that your reasoning (that it is “slow”) is quite un-sustainable.   And it would remain so, even if you had a billion trackpoints to write.

This program is, and always will be, I/O bound.   Its completion rate will always be wholly and completely driven by the speed and efficiency of the input/output hardware.   Meanwhile, I am quite sure that it could be demonstrated that the CPU could complete one billion date/time calculations in far less than one second’s time ... and I am being generous in my estimation.

Write the computational code in the simplest, clearest, and most-general way that you can.

“Don’t diddle the code to make it faster.”
– The Elements of Programming Style

Replies are listed 'Best First'.
Re^2: Simple date and time manipulation
by Corion (Pope) on Jan 19, 2011 at 13:43 UTC

    To expand a bit on BrowserUk's terse reply:

    Our target is to execute 1 billion such calculations in one second.

    Let's assume that "the CPU" can execute 1 date/time calculation per time step.

    We will need to execute 1 billion CPU time steps within one second. That is 1_000_000_000_000 time steps per second (burst, not sustained, mind you). So our CPU needs to run at 1000 GHz to meet that, never mind the overhead of fetching/storing the program or results.

    As 1000 GHz is still three magnitudes away and chip makers seem to have given up on the race of raw GHz, likely due to physical limits, maybe we can assume that "the CPU" has more than one core. "Mainline" CPUs (AMD or Intel) have something like 8 or 16 execution units per die, so these would need to run at 1000/16 GHz, still a bit far off. GPUs, albeit very specialized vector machines, are claimed to have "up to 512" CPUs (well, stream processors) in their marketing brochures (NVidia Geforce 500), but they only run at 750 MHz, or only 75% of what we need to come close to that claim.

    If you look at these numbers, and the simplifications I've made, I think you'll concede that your formulation of "one billion date/time calculations in far less than one second" is still a bit away in the future.

      Indeed. And that's if you wrote in machine code.

      But my proof is a little simpler, and more germane to the OPs situation. 10e7 takes three seconds, and that's just returning a constant, albeit not an optimised away one.

      C:\test>perl -MTime::HiRes=time -E"sub t{1}; $t=time; $x=t()for 1..1e7; printf qq[%f\n], time()-$t" 3.305000

      Not hard to verify.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Simple date and time manipulation
by BrowserUk (Pope) on Jan 19, 2011 at 13:31 UTC
    I am quite sure that it could be demonstrated that the CPU could complete one billion date/time calculations in far less than one secondís time

    Prove it!.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://883114]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2018-07-19 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (411 votes). Check out past polls.

    Notices?