Beispiel #1
0
def benchmark(datalogger, datestring):
    # get data, from datalogger, or dataloggerhelper
    starttime = time.time()
    #tsa = datalogger.read_tsa_full(datestring, force=True)
    tsa = timeit(datalogger.load_tsa, (datestring, ),  {"cleancache" : False})
    timeit(tsa.dump_split, ("/tmp/", ), {"overwrite":False})
    tsa2 = timeit(tsa.load_split, ("/tmp/", datalogger.index_keynames))
    assert tsa2 == tsa
    timeit(tsa.dump_to_csv, (gzip.open("/tmp/test_tsa.csv.gz", "wb"), ))
    tsa2 = timeit(TimeseriesArray.load_from_csv, (gzip.open("/tmp/test_tsa.csv.gz", "rb"), ))
    assert tsa == tsa2
    starttime = time.time()
    dumpduration = 0
    loadduration = 0
    for key, ts in tsa.items():
        dumpstart = time.time()
        filehandle = gzip.open("/tmp/test_ts.csv.gz", "wb")
        ts.dump_to_csv(filehandle)
        filehandle.close()
        dumpduration += time.time() - dumpstart
        loadstart = time.time()
        filehandle = gzip.open("/tmp/test_ts.csv.gz", "rb")
        ts2 = Timeseries.load_from_csv(filehandle)
        filehandle.close()
        loadduration += time.time() - loadstart
        try:
            assert ts == ts2
        except AssertionError as exc:
            print "Assertion Error on key %s" % str(key)
    print "cummulated dump duration : %f" % dumpduration
    print "cummulated load duration : %f" % loadduration
    print "CSV Export/Import single ts Duration %s" % (time.time() - starttime)
Beispiel #2
0
def shootout(datalogger, datestring):
    # get data, from datalogger, or dataloggerhelper
    tsa = datalogger.read_tsa_full(datestring, force=True)
    starttime = time.time()
    tsa.dump_to_csv(gzip.open("/tmp/test_tsa.csv.gz", "wb"))
    tsa2 = TimeseriesArray.load_from_csv(gzip.open("/tmp/test_tsa.csv.gz", "rb"))
    assert tsa == tsa2
    print "CSV Export/Import of whole tsa Duration %s" % (time.time() - starttime)
    starttime = time.time()
    cPickle.dump(tsa, gzip.open("/tmp/test_tsa_cPickle.gz", "wb"))
    tsa2 = cPickle.load(gzip.open("/tmp/test_tsa_cPickle.gz", "rb"))
    assert tsa == tsa2
    print "cPickle Export/Import of whole tsa Duration %s" % (time.time() - starttime)
    starttime = time.time()
    for key, ts in tsa.items():
        filehandle = gzip.open("/tmp/test_ts.csv.gz", "wb")
        ts.dump_to_csv(filehandle)
        filehandle.close()
        filehandle = gzip.open("/tmp/test_ts.csv.gz", "rb")
        ts2 = Timeseries.load_from_csv(filehandle)
        filehandle.close()
        #print ts2
        #print ts.ts_keyname, ts2.ts_keyname
        #print ts.headers, ts2.headers
        #print key, ts == ts2
        assert ts == ts2
    print "CSV Export/Import Duration %s" % (time.time() - starttime)
    starttime = time.time()
    for key, ts in tsa.items():
        filehandle = gzip.open("/tmp/test1.cPickle.gz", "wb")
        cPickle.dump(ts, filehandle)
        filehandle.close()
        filehandle = gzip.open("/tmp/test1.cPickle.gz", "rb")
        ts2 = cPickle.load(filehandle)
        filehandle.close()
        #print ts2
        #print ts.ts_keyname, ts2.ts_keyname
        #print ts.headers, ts2.headers
        #print key, ts == ts2
        assert ts == ts2
    print "cPickle Export/Import Duration %s" % (time.time() - starttime)
    #keys = tsa.keys()
    #for slottime in get_slot_timeline(datestring, 600):
    #    print slottime, slottime in tsa[keys[0]].get_times()
    #    #print tuple((tsa[key].get_single_value(slottime, 'hrStorageAllocationFailures') for key in keys))

    return