buildkite / terminal-to-html

Converts arbitrary shell output (with ANSI) into beautifully rendered HTML
http://buildkite.github.io/terminal-to-html
MIT License
651 stars 45 forks source link

Replace Ruby with Go #14

Closed mipearson closed 9 years ago

mipearson commented 9 years ago

As you were curious re the memory usage, NPM was 70ms/op and 27mb/op. Not sure what that translates to when run from the CLI (as I know that Go's own runtime adds a fair bit of weight)

BenchmarkRendererControl      300000          5298 ns/op        1584 B/op         14 allocs/op
BenchmarkRendererCurl      20000         55241 ns/op        9346 B/op         62 allocs/op
BenchmarkRendererHomer     10000        137403 ns/op       36858 B/op        222 allocs/op
BenchmarkRendererPikachu         300       4895747 ns/op     1392493 B/op      52659 allocs/op
BenchmarkRendererNpm          20      77312838 ns/op    27274740 B/op     542428 allocs/op
ok      github.com/buildkite/terminal   8.449s
toolmantim commented 9 years ago

Awesome! Have to get this up and going on my local puter.

toolmantim commented 9 years ago

So I sent our new terminal gear live on Monday, seems to be going well. It now shells out to the Ruby terminal gem, does the string encoding forcing in Ruby beforehand, and the unicode emojification afterwards. So dropping it for ansi2html should be a cinch. I'll probably feature flag it so we can test with a bunch of accounts first.

I'm wondering… should we keep this repo alive as terminal-ruby with an "unmaintained notice" in the Readme, and leave the gem on rubygems, and start this as a new repo?

mipearson commented 9 years ago

Up to you! I'd probably just leave a branch or tag as "last ruby commit" or something.

toolmantim commented 9 years ago

Just did some testing on a 4MB log:

$ time cat log_4MB.txt | ansi2html > /dev/null

real    0m0.623s
user    0m0.537s
sys 0m0.091s
$ time cat log_4MB.txt | terminal > /dev/null

real    0m8.724s
user    0m7.987s
sys 0m0.587s

Couldn't tell the memory usage for ansi2html because it executed so quickly… whereas terminal hits 1.4GB.

Now just doing some diffing to see if there's any difference in output…

toolmantim commented 9 years ago

Diffs look good!

Thinking of names… being this is "Terminal" and the command is "ansi2html"… and did a search and found https://github.com/ralphbean/ansi2html/

mipearson commented 9 years ago

Yeah - I'd certainly keep the library name as 'terminal'. Maybe the command can be terminal-convert ?

mipearson commented 9 years ago

So, thanks to Andy Snow (https://twitter.com/andy_snow/status/570409324322770945):

What happens if you use GNU time with -v?

Look for "Maximum resident set size (kbytes)"

You can install GNU time on OSX with brew install gnu-time or, if already on Linux, just call /usr/bin/time (instead of shell time)

mipearson commented 9 years ago

I made a 4mb file by concatenating npm.sh.raw with itself a bunch of times. Running that with GNU time -v on OSX gives me in Go a runtime of 1.06sec, with a maximum RSS of 816mb.

Switching back to Ruby, I get 9.2s and 3106gb RSS.

An improvement on the RSS, but .. I wonder if I can do better :)

toolmantim commented 9 years ago

Ace! Looks good.

Yeah, perhaps terminal-to-html?

toolmantim commented 9 years ago

And keep the go lib as terminal?

mipearson commented 9 years ago

WFM, done.

On Wed, Feb 25, 2015 at 1:55 PM, Tim Lucas notifications@github.com wrote:

And keep the go lib as terminal?

— Reply to this email directly or view it on GitHub https://github.com/buildkite/terminal/pull/14#issuecomment-75896626.

Michael Pearson