Skip to content

Instantly share code, notes, and snippets.

@motiejus
Last active June 19, 2018 23:29
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 motiejus/3312ce433038624d89163675d05c3eea to your computer and use it in GitHub Desktop.
Save motiejus/3312ce433038624d89163675d05c3eea to your computer and use it in GitHub Desktop.
timer
#!/usr/bin/env python -u
from sys import stdin, stdout
from datetime import datetime
before, line = datetime.utcnow(), 'foo'
while line != '':
line = stdin.readline()
ret = "[%s] %s" % (datetime.utcnow().strftime("%H:%M:%S.%f"), line)
stdout.write(ret)
diff = datetime.utcnow() - before
stdout.write("Total: %.6fs\n" % diff.total_seconds())
@motiejus
Copy link
Author

motiejus commented Jun 19, 2018

$ go --help 2>&1 | ./t | pbcopy
[23:28:57.801453] Go is a tool for managing Go source code.
[23:28:57.802445] 
[23:28:57.802469] Usage:
[23:28:57.802481] 
[23:28:57.802521] 	go command [arguments]
[23:28:57.802532] 
[23:28:57.802564] The commands are:
[23:28:57.802575] 
[23:28:57.802643] 	build       compile packages and dependencies
[23:28:57.802715] 	clean       remove object files and cached files
[23:28:57.802793] 	doc         show documentation for package or symbol
[23:28:57.802860] 	env         print Go environment information
[23:28:57.802910] 	bug         start a bug report
[23:28:57.802976] 	fix         update packages to use new APIs
[23:28:57.803045] 	fmt         gofmt (reformat) package sources
[23:28:57.803119] 	generate    generate Go files by processing source
[23:28:57.803205] 	get         download and install packages and dependencies
[23:28:57.803290] 	install     compile and install packages and dependencies
[23:28:57.803362] 	list        list packages
[23:28:57.803424] 	run         compile and run Go program
[23:28:57.803467] 	test        test packages
[23:28:57.803521] 	tool        run specified go tool
[23:28:57.803568] 	version     print Go version
[23:28:57.803638] 	vet         report likely mistakes in packages
[23:28:57.803649] 
[23:28:57.803736] Use "go help [command]" for more information about a command.
[23:28:57.803748] 
[23:28:57.803788] Additional help topics:
[23:28:57.803799] 
[23:28:57.803856] 	c           calling between Go and C
[23:28:57.803897] 	buildmode   build modes
[23:28:57.803953] 	cache       build and test caching
[23:28:57.803992] 	filetype    file types
[23:28:57.804054] 	gopath      GOPATH environment variable
[23:28:57.804107] 	environment environment variables
[23:28:57.804157] 	importpath  import path syntax
[23:28:57.804201] 	packages    package lists
[23:28:57.804245] 	testflag    testing flags
[23:28:57.804294] 	testfunc    testing functions
[23:28:57.804305] 
[23:28:57.804391] Use "go help [topic]" for more information about that topic.
[23:28:57.804402] 
[23:28:57.804413] Total: 0.003201s

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