From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Tue, 17 May 2011 03:37:33 -0400 To: 9fans@9fans.net Message-ID: In-Reply-To: <8D4049D0-5A78-4277-A0D1-9B70B32BC941@9srv.net> References: <8D4049D0-5A78-4277-A0D1-9B70B32BC941@9srv.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] toy: pseudo-sparklines Topicbox-Message-UUID: e4a9f88a-ead6-11e9-9d60-3106f5b1d025 > Roughly inspired by a writeup of some guy's python > implementation[2] of a generator, I threw one together this > afternoon in rc and hoc: [3] >=20 > :; sparkline 0 2 4 7 12 16 3 11 9 0 4=20 > =E2=96=81=E2=96=82=E2=96=83=E2=96=84=E2=96=87=E2=96=88=E2=96=82=E2=96=86= =E2=96=85=E2=96=81=E2=96=83:;=20 >=20 > The internet has noted that in some contexts the baseline gets > messed up, but they're still a fun toy. >=20 > Also, thanks to lmnop in #plan9 for this: >=20 > fn moustache { sparkline `{seq 0 1 10} `{seq 9 -1 0} ; echo } thanks for the toy! in addition to being naturally fun, it was interesting to play with. i initially ran your program directly from sources. since my path is the default, one could see each character print. (1985 says hi!) just for fun, i decided to modify sparkline to do a constant number of execs by pipelining most of the work. /n/sources/contrib/quanstro/spa= rkline. (yes, this is pointless.) since run time should be dominated by execs, the fewer the better. here's the comparison. n is the number of input numbers. orig 5n + 0 mod 0 + 12 (or 11 if you don't add the trailing \n.) and here's the actual run time for moustache (on an atom) local from sources orig 0.03u 0.12s 0.37r 0.03u 0.12s 5.26r mod 0.02u 0.02s 0.06r 0.01u 0.03s 0.86r exercize for bored reader: replace one sed with a hoc function. - erik