# cPy - compare various logger imolementations
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2026-06-11  initial release

import	time
from	file_utilities	import	fExists, fRemove, fSize
from	logger_dict		import	Logger	as Ld
from	logger_list		import	Logger	as Ll
from	logger_bytes	import	Logger	as Lb
from	logger_array	import	Logger	as La
from	logger_btree	import	Logger	as Lt


def test():
    fn = 'logger.data'
    if fExists(fn): fRemove(fn)
    for Log, descr in zip((Ld, Ll, Lb, La, Lt), ('dict', 'list', 'bytes', 'array', 'btree')):
        db = Log(1000, fn)
        t1 = time.ticks_ms()
        for _ in range(1000): db.append(5)
        t2 = time.ticks_ms()
        db.save()
        dt = time.ticks_diff(t2, t1)
        print(f'{descr:6}  {dt:>5} uSec  {fSize(fn):>5} bytes')
        
        
test()
                         