Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/python/benchUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import math
import os
import pickle
Expand Down Expand Up @@ -946,13 +947,20 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac
print(" cd %s" % s)
os.chdir(s)

# Create timestamped log subdirectory to avoid conflicts between runs
now = datetime.datetime.now()
timeStamp = "%04d.%02d.%02d.%02d.%02d.%02d" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked Claude to change this fragment to use strftime instead:

now = datetime.datetime.now()
timeStamp = now.strftime("%Y.%m.%d.%H.%M.%S")

https://claude.ai/share/a8042a55-733f-4c9e-91f3-b8c2d71c3bad

A bit more compact maybe :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure let me update this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in my latest commit, please check.

runLogDir = f"{constants.LOGS_DIR}/{id}/{timeStamp}"
os.makedirs(runLogDir, exist_ok=True)
print(f" log dir {runLogDir}")

try:
cmd = []
cmd += index.javaCommand.split()
w = lambda *xs: [cmd.append(str(x)) for x in xs]
w("-classpath", classPathToString(getClassPath(index.checkout)))

jfrOutput = f"{constants.LOGS_DIR}/bench-index-{id}-{index.getName()}.jfr"
jfrOutput = f"{runLogDir}/bench-index-{id}-{index.getName()}.jfr"

# 77: always enable Java Flight Recorder profiling
w(
Expand Down Expand Up @@ -1048,16 +1056,16 @@ def makeIndex(self, id, index, printCharts=False, profilerCount=30, profilerStac
if index.quantizeKNNGraph:
w("-quantizeKNNGraph")

fullLogFile = "%s/%s.%s.log" % (constants.LOGS_DIR, id, index.getName())
fullLogFile = "%s/%s.%s.log" % (runLogDir, id, index.getName())

print(" log %s" % fullLogFile)

t0 = time.time()
if VMSTAT_PATH is not None:
vmstatLogFile = f"{constants.LOGS_DIR}/{id}.vmstat.log"
vmstatLogFile = f"{runLogDir}/{id}.vmstat.log"
else:
vmstatLogFile = None
topLogFile = f"{constants.LOGS_DIR}/{id}.top.log"
topLogFile = f"{runLogDir}/{id}.top.log"
run(cmd, fullLogFile, vmstatLogFile=vmstatLogFile, topLogFile=topLogFile)
t1 = time.time()
if printCharts and IndexChart.Gnuplot is not None:
Expand Down