Skip to content

Instantly share code, notes, and snippets.

@MostAwesomeDude
Created April 9, 2021 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MostAwesomeDude/af932a4c56a5661934312c4b68f0531d to your computer and use it in GitHub Desktop.
Save MostAwesomeDude/af932a4c56a5661934312c4b68f0531d to your computer and use it in GitHub Desktop.
Derive stats from history-v2 feeds on https://channels.nix.gsc.io/
import "lib/codec/utf8" =~ [=> UTF8]
import "lib/streams" =~ [=> collectBytes]
import "lib/welford" =~ [=> makeWelford]
exports (main)
def main(_argv, => stdio) as DeepFrozen:
def bs := collectBytes(stdio<-stdin())
return when (bs) ->
def w := makeWelford()
for line in (bs.split(b`$\n`)):
if (line =~ b`@_commit @start @stop`):
def startTime := _makeInt.fromBytes(start)
def stopTime := _makeInt.fromBytes(stop)
w((stopTime - startTime).asDouble())
def stdout := stdio<-stdout()
def summary := `Mean: ${w.mean()} Std. Dev.: ${w.standardDeviation()} Skew: ${w.skew()} Kurtosis: ${w.kurtosis()}`
when (stdout<-(UTF8.encode(summary, null)), stdout<-complete()) -> { 0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment