Skip to content

Instantly share code, notes, and snippets.

@podhmo
Last active May 25, 2021 12:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save podhmo/cdcbf37501c59d8f2692596d42062e2f to your computer and use it in GitHub Desktop.
import sys
from datetime import datetime
def run(s):
lines = s.splitlines()
lhs, rhs = lines[0].split("\t", 1)
dt = datetime.strptime(lhs[:19], "%Y-%m-%dT%H:%M:%S")
for line in lines[1:]:
prev_rhs = rhs
lhs, rhs = line.split("\t", 1)
prev, dt = dt, datetime.strptime(lhs[:19], "%Y-%m-%dT%H:%M:%S")
print("{:6}\t{}".format((dt - prev).seconds, prev_rhs))
print("{:6}\t{}".format(0, rhs))
LINES = s = """\
2021-05-25T10:18:30.4725058Z\tsdist Set up job
2021-05-25T10:18:33.4769378Z\tsdist Run actions/checkout@v2
2021-05-25T10:18:43.9009378Z\tsdist Run actions/setup-python@v2
2021-05-25T10:18:43.9731147Z\tsdist Run /./.github/actions
2021-05-25T10:25:16.1305668Z\tsdist Post Run actions/checkout@v2
2021-05-25T10:25:16.2849272Z\tsdist Complete job
"""
if sys.stdin.isatty():
run(LINES)
else:
run(sys.stdin.read())
@podhmo
Copy link
Author

podhmo commented May 25, 2021

$ gh -R denoland/deno run view --job 2662718344 --log | ruby -ne 'if $_ =~ /(.+)\s+(20\d{2}-\d{2}-\d{2}T\S+)/ then prev,cur=cur,$1; puts "#{$2}\t#{cur}" if prev != cur; end' | python /tmp/x.py
     4  bench release ubuntu-latest-xl  Set up job
     0  bench release ubuntu-latest-xl  Configure git
    33  bench release ubuntu-latest-xl  Clone repository
    10  bench release ubuntu-latest-xl  Install rust
     2  bench release ubuntu-latest-xl  Install Deno
     0  bench release ubuntu-latest-xl  Error on Warning
     0  bench release ubuntu-latest-xl  Install Python
     3  bench release ubuntu-latest-xl  Install Node
     0  bench release ubuntu-latest-xl  Log versions
     4  bench release ubuntu-latest-xl  Cache Cargo home
    38  bench release ubuntu-latest-xl  Cache build output (PR)
     0  bench release ubuntu-latest-xl  Skip save cache (PR)
     8  bench release ubuntu-latest-xl  Apply and update mtime cache
   383  bench release ubuntu-latest-xl  Build release
     0  bench release ubuntu-latest-xl  Post Clone repository
     0  bench release ubuntu-latest-xl  Complete job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment