From 1783cb60c77c4ff53e8acc8644f7b03bea95bef5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey Date: Thu, 17 Jul 2014 01:23:10 +0100 Subject: [PATCH] minor: simplify analysis readme line --- README.md | 3 +- .../src/osta/osta.py | 11 +++++++ .../src/ostagraph.py | 33 +++++++++++-------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index df12465..7a17a61 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,7 @@ individual READMEs ## analysis ## -Tools for analysing OpenSimulator or related data files and for extracting -relevant system information. +Tools for analysing OpenSimulator or related data files. ## commands ## diff --git a/analysis/opensimulator-stats-analyzer/src/osta/osta.py b/analysis/opensimulator-stats-analyzer/src/osta/osta.py index b22865a..5ffff22 100755 --- a/analysis/opensimulator-stats-analyzer/src/osta/osta.py +++ b/analysis/opensimulator-stats-analyzer/src/osta/osta.py @@ -45,6 +45,17 @@ class OSimStatsCorpus: else: return None + def getStats(self, glob): + matchingStats = [] + + for category, containers in self._data.items(): + for container, stats in containers.items(): + for statName, stat in stats.items(): + if fnmatch.fnmatch(stat['fullName'], glob): + matchingStats.append(stat) + + return matchingStats + """Clear out any existing dataset.""" def clear(self): self._data = {} diff --git a/analysis/opensimulator-stats-analyzer/src/ostagraph.py b/analysis/opensimulator-stats-analyzer/src/ostagraph.py index 19bb9d2..a297263 100755 --- a/analysis/opensimulator-stats-analyzer/src/ostagraph.py +++ b/analysis/opensimulator-stats-analyzer/src/ostagraph.py @@ -2,6 +2,7 @@ import argparse import matplotlib.pyplot as plt +import sys from pylab import * from osta.osta import * @@ -22,24 +23,30 @@ parser.add_argument( parser.add_argument( 'statsLogPath', help = "Path to the stats log file.", - metavar = "stats-log-path") + metavar = "stats-log-path", + nargs='*') opts = parser.parse_args() corpus = OSimStatsCorpus() -corpus.parse(opts.statsLogPath) -stat = corpus.getStat(opts.select) +for path in opts.statsLogPath: + corpus.parse(path) -if not stat == None: - plt.plot(stat['abs']['values']) - plt.title(stat['fullName']) - plt.xlabel("samples") - plt.ylabel(stat['name']) +stats = corpus.getStats(opts.select) + +if len(stats) <= 0: + print "No stats matching %s" % (opts.select) + sys.exit(1) + +plt.title(opts.select) +plt.ylabel(stats[0]['name']) + +for stat in stats: + plt.plot(stat['abs']['values']) + plt.xlabel("samples") - if 'out' in opts: - savefig(opts.out) - else: - plt.show() +if 'out' in opts: + savefig(opts.out) else: - print "No such stat as %s" % (opts.select) \ No newline at end of file + plt.show() \ No newline at end of file