9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] toy: pseudo-sparklines
Date: Tue, 17 May 2011 03:37:33 -0400	[thread overview]
Message-ID: <fbf0a6931f0fc29aa7a27f0d07f36897@ladd.quanstro.net> (raw)
In-Reply-To: <8D4049D0-5A78-4277-A0D1-9B70B32BC941@9srv.net>

> 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]
> 
> 	:; sparkline 0 2 4 7 12 16 3 11 9 0 4 
> 	▁▂▃▄▇█▂▆▅▁▃:; 
> 
> The internet has noted that in some contexts the baseline gets
> messed up, but they're still a fun toy.
> 
> Also, thanks to lmnop in #plan9 for this:
> 
> 	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/sparkline.
(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



      reply	other threads:[~2011-05-17  7:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17  4:25 Anthony Sorace
2011-05-17  7:37 ` erik quanstrom [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbf0a6931f0fc29aa7a27f0d07f36897@ladd.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).