I needed to cycle through a collection of external files, but I wanted to do it in a random order, and I also wanted to go through all of the files before I went through any file twice.
There are all sorts of ways to implement this, so that's not really a big deal. Somewhere I had an error that was giving me repeated files before I had finished a complete cycle, so I need to track that down, and I did, and it was fixed.
But was it really fixed? I wondered how I could test this. I could simply count every time I saw the file and compare all the counts at various times. That works.
I wanted to watch it though. I didn't want to speed read as a bunch of text lines scrolled past on the terminal. I wanted so compact output that would fit on the screen and updated as things happened, so I wrote a little Curses visualizer.
The particulars of the program aren't important. It output a string with two numbers which identified the resource. The first number was between 1 and 9 and the second was between 1 and 80. On the screen, I framed a matrix for these. At the right spot, I'd put something on the screen to show something just happened for the file with those two numbers.
I started with the count of the times I had seen that file. When I saw the file once, I'd put a "1" in the matrix, when I saw it twice, a "2", and so on. That kinda worked, but it was hard to read. Then I used other characters in place of number and alternated between characters with lots of empty space and those without a lot, such as ( . @ ^ # , $ | & + ). That was better, but still not good enough. I was running this things for a couple implementations and I wanted to see an anomaly instantly.
I changed to simple, colored blocks instead of characters. I just made a bunch of Curses pairs that had the same foreground and background and assigned each color to a number of times I saw the file. I went in the order of the rainbow: blue for 1 time, green for 2 times, and so on.
Too bad I can't show some images inline, so you'll have to be satisfied with some external images: first pass through the corpus (black is 0 times and blue is 1 time ), second pass (green is 2 times).
I could have also done this with sound by playing a specific pitch for each count and I wouldn't even have to watch it. I could almost tune out because the odd pitch would get my attention.
#!/usr/bin/perl use Curses; init(); make_frame(); while(1) { my( $M, $m ) = `command` =~ m/M: (\d+), m: (\d+)$/g; put( $M, $m, ++$count{$M}{$m} ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sub init { $SIG{__DIE__} = $SIG{TERM} = sub { endwin; exit }; instiller; curs_set(0); start_color(); my @colors = ( COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_YELLOW, COLOR_RED ); foreach my $color ( 1 .. @colors ) { init_pair( $color, ( $colors[ $color ] ) x 2 ) } } sub make_frame { foreach my $y ( 1 .. 80 ) { my $Y = $y; if( $y % 10 == 0 ) { $y /= 10 }; $y %= 10; addch( 0, $Y+1, "$y" ); addch( 10, $Y+1, "$y" ); } foreach my $x ( 1 .. 9 ) { addch( $x, 1, "$x" ); addch( $x, 82, "$x" ); } refresh; } sub put { my( $major, $minor, $n ) = @_; attron( COLOR_PAIR($n) ); addch( $major, $minor+2, " " ); attroff( COLOR_PAIR($n) ); refresh; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Visualizing bugs
by graff (Chancellor) on Dec 19, 2004 at 22:26 UTC | |
by brian_d_foy (Abbot) on Dec 20, 2004 at 01:29 UTC | |
by qq (Hermit) on Dec 21, 2004 at 01:31 UTC | |
by graff (Chancellor) on Dec 21, 2004 at 02:48 UTC | |
|
Re: Visualizing bugs
by CountZero (Bishop) on Dec 19, 2004 at 17:43 UTC | |
|
Re: Visualizing bugs
by The Mad Hatter (Priest) on Dec 19, 2004 at 18:14 UTC | |
by tye (Sage) on Dec 20, 2004 at 06:34 UTC | |
by gaal (Parson) on Dec 20, 2004 at 06:50 UTC | |
by runrig (Abbot) on Dec 20, 2004 at 17:04 UTC | |
by gaal (Parson) on Dec 20, 2004 at 17:52 UTC | |
| |
by hv (Prior) on Dec 20, 2004 at 13:05 UTC | |
by BrowserUk (Patriarch) on Dec 20, 2004 at 13:32 UTC | |
by gaal (Parson) on Dec 20, 2004 at 16:23 UTC | |
by BrowserUk (Patriarch) on Dec 20, 2004 at 16:39 UTC | |
| |
by Anonymous Monk on Dec 20, 2004 at 17:19 UTC | |
|
Re: Visualizing bugs
by dragonchild (Archbishop) on Dec 20, 2004 at 13:58 UTC |