Skip to content

Instantly share code, notes, and snippets.

@nad2000
Last active December 31, 2015 04:59
Show Gist options
  • Save nad2000/7937492 to your computer and use it in GitHub Desktop.
Save nad2000/7937492 to your computer and use it in GitHub Desktop.
1) removes all lines except relevant: - iteration parameter; - tps (excluding connection time). 2) joins lines together to form CSV file.
egrep "(\*\*\*\*|excluding)" test.log | sed '/tps/ s/tps = \([.0-9]*\) .*/\1/; /uview/ s/ uview\([0-9]*\)/\1/' | sed -n '/\**/ {N;s/\n/,/;N;s/\n/,/;s/\**//p}'
## With loading into PostgreSQL:
# Create table:
psql -d 5 -c "create table test_output( id int, tps1 numeric, tps2 numeric)"
# Extract and load data:
egrep "(\*\*\*\*|excluding)" test.log | sed '/tps/ s/tps = \([.0-9]*\) .*/\1/; /uview/ s/ uview\([0-9]*\)/\1/' | sed -n '/\**/ {N;s/\n/,/;N;s/\n/,/;s/\**//p}' | psql -d 5 -c "TRUNCATE TABLE test_output; COPY test_output FROM STDIN (FORMAT csv, DELIMITER ',', HEADER false)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment