30% faster folder listings (wtf...)

This commit is contained in:
ed 2023-04-26 18:55:53 +00:00
parent 673b4f7e23
commit 55c74ad164
3 changed files with 24 additions and 4 deletions

1
.gitignore vendored
View file

@ -37,6 +37,7 @@ up.*.txt
.hist/
scripts/docker/*.out
scripts/docker/*.err
/perf.*
# nix build output link
result

View file

@ -3604,7 +3604,14 @@ class HttpCli(object):
sz = inf.st_size
zd = datetime.utcfromtimestamp(linf.st_mtime)
dt = zd.strftime("%Y-%m-%d %H:%M:%S")
dt = "%04d-%02d-%02d %02d:%02d:%02d" % (
zd.year,
zd.month,
zd.day,
zd.hour,
zd.minute,
zd.second,
)
try:
ext = "---" if is_dir else fn.rsplit(".", 1)[1]

View file

@ -647,8 +647,14 @@ class SvcHub(object):
return
with self.log_mutex:
ts = datetime.utcnow().strftime("%Y-%m%d-%H%M%S.%f")[:-3]
self.logf.write("@{} [{}\033[0m] {}\n".format(ts, src, msg))
zd = datetime.utcnow()
ts = "%04d-%04d-%06d.%03d" % (
zd.year,
zd.month * 100 + zd.day,
(zd.hour * 100 + zd.minute) * 100 + zd.second,
zd.microsecond // 1000,
)
self.logf.write("@%s [%s\033[0m] %s\n" % (ts, src, msg))
now = time.time()
if now >= self.next_day:
@ -693,7 +699,13 @@ class SvcHub(object):
else:
msg = "{}{}\033[0m".format(c, msg)
ts = datetime.utcfromtimestamp(now).strftime("%H:%M:%S.%f")[:-3]
zd = datetime.utcfromtimestamp(now)
ts = "%02d:%02d:%02d.%03d" % (
zd.hour,
zd.minute,
zd.second,
zd.microsecond // 1000,
)
msg = fmt.format(ts, src, msg)
try:
print(msg, end="")