Skip to content

Commit 820e1e5

Browse files
committed
Create DB in memory
1 parent af59309 commit 820e1e5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

preciceprofiling/merge.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,25 @@ def mergeCommand(files, outfile, align):
466466
resolved = detectFiles(files)
467467
sanitized = sanitizeFiles(resolved)
468468

469+
# Remove the old DB if present
469470
outfile.unlink(missing_ok=True)
470-
con = sqlite3.connect(outfile)
471+
472+
# We create the db in-memory and safe it to disk later (10% faster)
473+
con = sqlite3.connect(":memory:")
471474

472475
loadProfilingOutputs(con, sanitized)
473476

474477
if align:
475478
alignEvents(con)
476479

477-
# commit and tidy up
478-
con.commit()
479480
createIndices(con)
480-
con.execute("VACUUM")
481+
con.commit()
482+
483+
# Backup the in-memory DB to a blank DB on disk
484+
filedb = sqlite3.connect(outfile)
485+
con.backup(filedb)
481486
con.close()
487+
filedb.close()
482488

483489
return 0
484490

0 commit comments

Comments
 (0)