[libcxx-commits] [libcxx] 6a7aec1 - [libc++] Fix bug with appending and overwriting in benchmark-historical

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 23 10:10:09 PDT 2025


Author: Louis Dionne
Date: 2025-09-23T13:09:56-04:00
New Revision: 6a7aec12ad359476c2c4dadce05dfef384187901

URL: https://github.com/llvm/llvm-project/commit/6a7aec12ad359476c2c4dadce05dfef384187901
DIFF: https://github.com/llvm/llvm-project/commit/6a7aec12ad359476c2c4dadce05dfef384187901.diff

LOG: [libc++] Fix bug with appending and overwriting in benchmark-historical

The logic was wrong when the data file did not already exist but we were
in 'append' mode.

Added: 
    

Modified: 
    libcxx/utils/benchmark-historical

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/benchmark-historical b/libcxx/utils/benchmark-historical
index 7bba2128cf4d9..c1f9d11a6e800 100755
--- a/libcxx/utils/benchmark-historical
+++ b/libcxx/utils/benchmark-historical
@@ -91,13 +91,13 @@ def main(argv):
 
             subprocess.call(test_cmd)
             output_file.parent.mkdir(parents=True, exist_ok=True)
+            mode = 'a' if args.existing == 'append' else 'w'
             if output_file.exists() and args.existing == 'append':
                 logging.info(f'Appending to existing data for {commit}')
-                mode = 'a'
-            else:
-                assert args.existing == 'overwrite'
+            elif output_file.exists() and args.existing == 'overwrite':
                 logging.info(f'Overwriting existing data for {commit}')
-                mode = 'w'
+            else:
+                logging.info(f'Writing data for {commit}')
             with open(output_file, mode) as out:
                 subprocess.check_call([(PARENT_DIR / 'consolidate-benchmarks'), build_dir], stdout=out)
 


        


More information about the libcxx-commits mailing list