mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Improve performance-plot script
- Add option to select commands for display - Use name of data directory as plot title Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
b87f4a1f5c
commit
8d1b89db30
1 changed files with 11 additions and 5 deletions
|
@ -1,32 +1,38 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
|
||||
import os
|
||||
|
||||
import argparse
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
parser = argparse.ArgumentParser(description='Display performance plots.')
|
||||
parser.add_argument('output_dir',
|
||||
help='directory containing the measurement files')
|
||||
parser.add_argument('output_dir', help='directory containing the measurement files')
|
||||
parser.add_argument('commands', nargs='*', type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
output_directory = args.output_dir
|
||||
commands = args.commands
|
||||
|
||||
plt.axes([0.1, 0.1, 0.6, 0.75])
|
||||
plt.xlabel("# database entries")
|
||||
plt.ylabel("time [s]")
|
||||
plt.title("timew performance")
|
||||
plt.title(output_directory)
|
||||
|
||||
for filename in os.listdir(output_directory):
|
||||
if filename.endswith(".log"):
|
||||
cmd = "-".join(filename.split('-')[1:-1])
|
||||
else:
|
||||
continue
|
||||
|
||||
if len(commands) == 0 or cmd in commands:
|
||||
try:
|
||||
x, y = np.loadtxt(os.path.join(output_directory, filename),
|
||||
delimiter='\t',
|
||||
usecols=(1, 2),
|
||||
unpack=True)
|
||||
plt.plot(x, y, label=cmd, marker=".", linestyle='')
|
||||
plt.plot(x, y, label=cmd, marker=".", linestyle='-')
|
||||
except ValueError as e:
|
||||
print("Invalid file: {} {}".format(filename, e))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue