[33002] in Perl-Users-Digest
Perl-Users Digest, Issue: 4278 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 26 05:17:17 2014
Date: Tue, 26 Aug 2014 02:17:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 26 Aug 2014 Volume: 11 Number: 4278
Today's topics:
Re: New topic: time flow simulation <gamo@telecable.es>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Aug 2014 09:09:37 +0200
From: gamo <gamo@telecable.es>
Subject: Re: New topic: time flow simulation
Message-Id: <lthbsj$bvs$1@speranza.aioe.org>
El 18/08/14 a las 16:53, gamo escribió:
> El 18/08/14 a las 14:02, Rainer Weikusat escribió:
>> gamo <gamo@telecable.es> writes:
>>> El 17/08/14 a las 22:04, Rainer Weikusat escribió:
>>>
>>>> [different way to do the same]
>>>>
>>>> There are various ways to implement the 'insane counting loop'. Once
>>>> that's slightly faster for me (on my seven-years-old 32-bit machine at
>>>> home) would be
>>>>
>>>> my ($day, $hour, $min, $next_sec, $sec, $milli, $timer);
>>>> do {
>>>> {
>>>> $next_sec = $timer + 1000;
>>>> 1 while ++$timer < $next_sec;
>>>>
>>>> $sec < 59 and ++$sec, redo;
>>>> $sec = 0;
>>>>
>>>> $min < 59 and ++$min, redo;
>>>> $min = 0;
>>>>
>>>> $hour < 23 and ++$hour, redo;
>>>> $hour = 0;
>>>> }
>>>> } while ++$day < 7;
>>>>
>>>> but as the code is completely useless as it stands, it's somewhat
>>>> difficult to reply anything meaningful.
>>>
>>> That does the same but it's not clear where is the place
>>> to insert the main block of conditionals to read input and call
>>> event subs.
>>
>> The
>>
>> 1 while ++$timer < $next_sec
>>
>> could be turned into a real inner-loop. I doubt (didn't test) that the
>> trick employed here to get rid of the explicit millisecond counter would
>> still be useful if a count of 'milliseconds since the last second' was
>> actually needed.
>>
>
> It's not needed because $timer is irrepetible and that's its
> best property.
>
> Thanks
>
>
In order to EOD, your code is the fastest, but to be effectively
used, the 1/1000 sec. must be reduced to 1/100 sec.
Here are the timings of the alternatives:
60480000
60480000
60480000
Time with loops is 9.63275384902954 s
Time with if's is 10.5904960632324 s
Time of Rainer's 8.73261308670044 s
Thanks, best regards.
--
http://www.telecable.es/personales/gamo/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4278
***************************************