ntpviz - Don't plot a line during data absence

Gary E. Miller gem at rellim.com
Sun Oct 23 20:31:50 UTC 2016


Yo Achim!

On Sun, 23 Oct 2016 21:16:00 +0200
Achim Gratz <Stromeko at nexgo.de> wrote:

> Gary E. Miller writes:
> > So, two float conversions per cycle.  If C you would do this to
> > change a float to a store to make it much faster:
> >
> >         # a is a string of the current time, b is a float of the
> > last time # c is a float of the current time
> >         c = float (a )
> > 	if 1024 < ( c - b):
> > 		# do something
> >         b = c
> >
> > In C that would be much faster, but in Python it is slower!  In
> > Python it seems to be slower to create a new variable than to
> > convert a string to a float.  
> 
> So don't create and destroy variable c each time round your loop.

Right, that was my initial hack.

> Create it once outside the loop and use it for assignment inside the
> loop and you might see the expected speedup.

Yes, the next logical step.  But that float subtract/compare is also 
painful.  I'm thinking of going integer milliseconds instead of floats.
But that adds a float multiply, so it may it work out.  Lot's to try.

Feel free to run some of your own profiles and share.


> Or not, depending on how
> clever Python gets when it sees that you use the same expression
> multiple times on the same argument.

Not an issue here.  Each loop has new unique values.

> I'm sure Python has ways to just read in all that data into a float
> array before you dive into the looping business.

PHP does a lot better than Python.  If you find a better way please
forward the patch and the profile to show the improvement.

> You'd generally be
> much better off using such a facility if it exists instead of trying
> to parse the data file line by line.

Certainly, and PHP does much better than Python on this regard.  I
found that an unpleasant surprise, I had thought Python was supposed to
be better at arrays than PHP, but not true.

Now if I can get Eric to code up some new Python functions in C for me?

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ntpsec.org/pipermail/devel/attachments/20161023/3f5d9846/attachment.bin>


More information about the devel mailing list