diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py deleted file mode 100644 index 12043bffa..000000000 --- a/benchmark/benchmark.py +++ /dev/null @@ -1,175 +0,0 @@ -"""Utility script for monty reverse reader speed benchmark. -- File of various sizes. -- Find the last line, 75 % line and 50 % line, and compare with reading from forwards. -""" - -from __future__ import annotations - -import os -import platform -import sys -import time - -from monty.io import reverse_readfile, reverse_readline - -# Test config -FILE_SIZES_MB = (1, 10, 100, 500, 1000, 5000) - - -def create_test_file(file_path, target_size_mb): - """Creates a text file with lines until the target size is reached.""" - target_size = target_size_mb * 1024 * 1024 # Convert MB to bytes - line_number = 1 - - start = time.perf_counter() - - # Create a list of lines and concatenate them at the end - lines = [] - total_bytes_written = 0 - - while total_bytes_written < target_size: - line = f"This is line number {line_number}\n" - line_bytes = line.encode("utf-8") - - if total_bytes_written + len(line_bytes) > target_size: - break - - lines.append(line) - total_bytes_written += len(line_bytes) - line_number += 1 - - with open(file_path, "wb") as f: - f.write("".join(lines).encode("utf-8")) - - last_time = time.perf_counter() - start - - total_lines = line_number - 1 - print( - f"Test file of size {target_size_mb} MB created with {total_lines} lines, time used {last_time:.2f} seconds." - ) - return total_lines - - -def print_separator(title: str): - print(f"{title}".center(80, "=")) - print("") - - -def test_builtin_readline(file_path, total_lines): - """Test built-in readline function.""" - start = time.perf_counter() - with open(file_path, "r") as f: - for _ in range(total_lines): - _last_line = f.readline() - last_time = time.perf_counter() - start - - line_75_idx = int(0.75 * total_lines) - line_50_idx = int(0.5 * total_lines) - - start = time.perf_counter() - with open(file_path, "r") as f: - for _ in range(line_75_idx + 1): - _line_75 = f.readline() - time_75 = time.perf_counter() - start - - start = time.perf_counter() - with open(file_path, "r") as f: - for _ in range(line_50_idx + 1): - _line_50 = f.readline() - time_50 = time.perf_counter() - start - - print_separator("Built-in readline") - print(f"Last line {total_lines} read, time taken: {last_time:.8f} s.") - print(f"75% line {line_75_idx} read, time taken: {time_75:.8f} s.") - print(f"50% line {line_50_idx} read, time taken: {time_50:.8f} s.") - print_separator("End of Built-in readline") - - return last_time, time_75, time_50 - - -def test_reverse_readline(file_path, total_lines): - """Test reverse_readline function.""" - start = time.perf_counter() - with open(file_path, "r") as f: - _last_line = next(reverse_readline(f)) - last_time = time.perf_counter() - start - - line_75_idx = int(0.75 * total_lines) - line_50_idx = int(0.5 * total_lines) - - start = time.perf_counter() - with open(file_path, "r") as f: - for idx, _line in enumerate(reverse_readline(f), 1): - if idx == total_lines - line_75_idx: - break - time_75 = time.perf_counter() - start - - start = time.perf_counter() - with open(file_path, "r") as f: - for idx, _line in enumerate(reverse_readline(f), 1): - if idx == total_lines - line_50_idx: - break - time_50 = time.perf_counter() - start - - print_separator("reverse_readline") - print(f"Last line {total_lines} read, time taken: {last_time:.8f} s.") - print(f"75% line {line_75_idx} read, time taken: {time_75:.8f} s.") - print(f"50% line {line_50_idx} read, time taken: {time_50:.8f} s.") - print_separator("End of reverse_readline") - - return last_time, time_75, time_50 - - -def test_reverse_readfile(file_path, total_lines): - """Test reverse_readfile function.""" - start = time.perf_counter() - _last_line = next(reverse_readfile(file_path)) - last_time = time.perf_counter() - start - - line_75_idx = int(0.75 * total_lines) - line_50_idx = int(0.5 * total_lines) - - start = time.perf_counter() - for idx, _line in enumerate(reverse_readfile(file_path), 1): - if idx == total_lines - line_75_idx: - break - time_75 = time.perf_counter() - start - - start = time.perf_counter() - for idx, _line in enumerate(reverse_readfile(file_path), 1): - if idx == total_lines - line_50_idx: - break - time_50 = time.perf_counter() - start - - print_separator("reverse_readfile") - print(f"Last line {total_lines} read, time taken: {last_time:.8f} s.") - print(f"75% line {line_75_idx} read, time taken: {time_75:.8f} s.") - print(f"50% line {line_50_idx} read, time taken: {time_50:.8f} s.") - print_separator("End of reverse_readfile") - - return last_time, time_75, time_50 - - -def run_benchmark(file_size_mb): - """Run benchmark for all test functions.""" - print_separator(f"Benchmarking file size: {file_size_mb} MB") - - test_file = f"test_file_{file_size_mb}MB.txt" - total_lines = create_test_file(test_file, file_size_mb) - - test_builtin_readline(test_file, total_lines) - test_reverse_readline(test_file, total_lines) - test_reverse_readfile(test_file, total_lines) - - os.remove(test_file) - - -if __name__ == "__main__": - # Show OS info - os_info = platform.platform() - python_version = sys.version.split()[0] - print(f"\nRunning on OS: {os_info}, Python {python_version}") - - # Run benchmark for each file size - for file_size_mb in FILE_SIZES_MB: - run_benchmark(file_size_mb) diff --git a/benchmark/develop-ubuntu2204.txt b/benchmark/develop-ubuntu2204.txt deleted file mode 100644 index a9f882fc7..000000000 --- a/benchmark/develop-ubuntu2204.txt +++ /dev/null @@ -1,145 +0,0 @@ - -Running on OS: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35, Python 3.12.5 -==========================Benchmarking file size: 1 MB========================== - -Test file of size 1 MB created with 40757 lines, time used 0.01 seconds. -===============================Built-in readline================================ - -Last line 40757 read, time taken: 0.00299960 s. -75% line 30567 read, time taken: 0.00225260 s. -50% line 20378 read, time taken: 0.00147340 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 40757 read, time taken: 0.00215450 s. -75% line 30567 read, time taken: 0.00299860 s. -50% line 20378 read, time taken: 0.00347230 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 40757 read, time taken: 0.00007200 s. -75% line 30567 read, time taken: 0.00393440 s. -50% line 20378 read, time taken: 0.00788680 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 10 MB========================== - -Test file of size 10 MB created with 392476 lines, time used 0.11 seconds. -===============================Built-in readline================================ - -Last line 392476 read, time taken: 0.02891790 s. -75% line 294357 read, time taken: 0.02203730 s. -50% line 196238 read, time taken: 0.01453720 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 392476 read, time taken: 0.00010690 s. -75% line 294357 read, time taken: 0.08467931 s. -50% line 196238 read, time taken: 0.16308102 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 392476 read, time taken: 0.00007110 s. -75% line 294357 read, time taken: 0.03886231 s. -50% line 196238 read, time taken: 0.07676581 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 100 MB========================= - -Test file of size 100 MB created with 3784596 lines, time used 1.11 seconds. -===============================Built-in readline================================ - -Last line 3784596 read, time taken: 0.28840513 s. -75% line 2838447 read, time taken: 0.22593426 s. -50% line 1892298 read, time taken: 0.14234112 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 3784596 read, time taken: 0.00010290 s. -75% line 2838447 read, time taken: 0.80831332 s. -50% line 1892298 read, time taken: 1.62029043 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 3784596 read, time taken: 0.00007960 s. -75% line 2838447 read, time taken: 0.35162211 s. -50% line 1892298 read, time taken: 0.70727881 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 500 MB========================= - -Test file of size 500 MB created with 18462038 lines, time used 5.24 seconds. -===============================Built-in readline================================ - -Last line 18462038 read, time taken: 1.38365400 s. -75% line 13846528 read, time taken: 1.11287734 s. -50% line 9231019 read, time taken: 0.69148150 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 18462038 read, time taken: 0.00009210 s. -75% line 13846528 read, time taken: 3.98585572 s. -50% line 9231019 read, time taken: 7.93171154 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 18462038 read, time taken: 0.00007860 s. -75% line 13846528 read, time taken: 1.75920299 s. -50% line 9231019 read, time taken: 3.45924340 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 1000 MB========================= - -Test file of size 1000 MB created with 36540934 lines, time used 10.33 seconds. -===============================Built-in readline================================ - -Last line 36540934 read, time taken: 2.79645362 s. -75% line 27405700 read, time taken: 2.20113669 s. -50% line 18270467 read, time taken: 1.37504352 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 36540934 read, time taken: 0.00009140 s. -75% line 27405700 read, time taken: 8.09242921 s. -50% line 18270467 read, time taken: 15.43773309 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 36540934 read, time taken: 0.00010630 s. -75% line 27405700 read, time taken: 3.53976401 s. -50% line 18270467 read, time taken: 7.18230309 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 5000 MB========================= - -Test file of size 5000 MB created with 178466370 lines, time used 59.52 seconds. -===============================Built-in readline================================ - -Last line 178466370 read, time taken: 14.19376238 s. -75% line 133849777 read, time taken: 10.26362936 s. -50% line 89233185 read, time taken: 6.69335968 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 178466370 read, time taken: 0.00255530 s. -75% line 133849777 read, time taken: 39.30825986 s. -50% line 89233185 read, time taken: 76.32949390 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 178466370 read, time taken: 0.00073260 s. -75% line 133849777 read, time taken: 18.99764580 s. -50% line 89233185 read, time taken: 37.87064222 s. -============================End of reverse_readfile============================= diff --git a/benchmark/develop-win11.txt b/benchmark/develop-win11.txt deleted file mode 100644 index c55682ce3..000000000 --- a/benchmark/develop-win11.txt +++ /dev/null @@ -1,145 +0,0 @@ - -Running on OS: Windows-11-10.0.22631-SP0, Python 3.12.5 -==========================Benchmarking file size: 1 MB========================== - -Test file of size 1 MB created with 40757 lines, time used 0.03 seconds. -===============================Built-in readline================================ - -Last line 40757 read, time taken: 0.01786360 s. -75% line 30567 read, time taken: 0.00689310 s. -50% line 20378 read, time taken: 0.00435630 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 40757 read, time taken: 0.00715640 s. -75% line 30567 read, time taken: 0.00793530 s. -50% line 20378 read, time taken: 0.00999800 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 40757 read, time taken: 0.00021470 s. -75% line 30567 read, time taken: 0.00589890 s. -50% line 20378 read, time taken: 0.01156540 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 10 MB========================== - -Test file of size 10 MB created with 392476 lines, time used 0.16 seconds. -===============================Built-in readline================================ - -Last line 392476 read, time taken: 0.08994260 s. -75% line 294357 read, time taken: 0.06407060 s. -50% line 196238 read, time taken: 0.04269250 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 392476 read, time taken: 0.00021460 s. -75% line 294357 read, time taken: 0.20066430 s. -50% line 196238 read, time taken: 0.40051340 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 392476 read, time taken: 0.00023090 s. -75% line 294357 read, time taken: 0.05876890 s. -50% line 196238 read, time taken: 0.11659210 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 100 MB========================= - -Test file of size 100 MB created with 3784596 lines, time used 1.79 seconds. -===============================Built-in readline================================ - -Last line 3784596 read, time taken: 0.89517130 s. -75% line 2838447 read, time taken: 0.66395980 s. -50% line 1892298 read, time taken: 0.43874380 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 3784596 read, time taken: 0.00024390 s. -75% line 2838447 read, time taken: 2.01433790 s. -50% line 1892298 read, time taken: 3.89665920 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 3784596 read, time taken: 0.00024540 s. -75% line 2838447 read, time taken: 0.55314700 s. -50% line 1892298 read, time taken: 1.10856910 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 500 MB========================= - -Test file of size 500 MB created with 18462038 lines, time used 8.46 seconds. -===============================Built-in readline================================ - -Last line 18462038 read, time taken: 4.11462000 s. -75% line 13846528 read, time taken: 3.03727910 s. -50% line 9231019 read, time taken: 2.00691610 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 18462038 read, time taken: 0.00023220 s. -75% line 13846528 read, time taken: 9.28227760 s. -50% line 9231019 read, time taken: 18.47311200 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 18462038 read, time taken: 0.00022390 s. -75% line 13846528 read, time taken: 2.60500570 s. -50% line 9231019 read, time taken: 5.27204600 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 1000 MB========================= - -Test file of size 1000 MB created with 36540934 lines, time used 16.16 seconds. -===============================Built-in readline================================ - -Last line 36540934 read, time taken: 8.21203530 s. -75% line 27405700 read, time taken: 6.17786950 s. -50% line 18270467 read, time taken: 4.08797350 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 36540934 read, time taken: 0.00021340 s. -75% line 27405700 read, time taken: 18.49044130 s. -50% line 18270467 read, time taken: 37.14956300 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 36540934 read, time taken: 0.00022620 s. -75% line 27405700 read, time taken: 5.27717680 s. -50% line 18270467 read, time taken: 10.61577650 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 5000 MB========================= - -Test file of size 5000 MB created with 178466370 lines, time used 82.48 seconds. -===============================Built-in readline================================ - -Last line 178466370 read, time taken: 40.74100250 s. -75% line 133849777 read, time taken: 30.38311240 s. -50% line 89233185 read, time taken: 20.11819820 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 178466370 read, time taken: 0.00158920 s. -75% line 133849777 read, time taken: 90.74261630 s. -50% line 89233185 read, time taken: 182.34117580 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 178466370 read, time taken: 0.00046110 s. -75% line 133849777 read, time taken: 27.03316890 s. -50% line 89233185 read, time taken: 53.99668290 s. -============================End of reverse_readfile============================= diff --git a/benchmark/pypi-7.12-ubuntu2204.txt b/benchmark/pypi-7.12-ubuntu2204.txt deleted file mode 100644 index ded5db11b..000000000 --- a/benchmark/pypi-7.12-ubuntu2204.txt +++ /dev/null @@ -1,145 +0,0 @@ - -Running on OS: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35, Python 3.12.5 -==========================Benchmarking file size: 1 MB========================== - -Test file of size 1 MB created with 40757 lines, time used 0.01 seconds. -===============================Built-in readline================================ - -Last line 40757 read, time taken: 0.00308300 s. -75% line 30567 read, time taken: 0.00226110 s. -50% line 20378 read, time taken: 0.00148280 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 40757 read, time taken: 0.00208500 s. -75% line 30567 read, time taken: 0.00314750 s. -50% line 20378 read, time taken: 0.00374380 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 40757 read, time taken: 0.00006290 s. -75% line 30567 read, time taken: 0.00327840 s. -50% line 20378 read, time taken: 0.00682650 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 10 MB========================== - -Test file of size 10 MB created with 392476 lines, time used 0.11 seconds. -===============================Built-in readline================================ - -Last line 392476 read, time taken: 0.03117800 s. -75% line 294357 read, time taken: 0.02239440 s. -50% line 196238 read, time taken: 0.01462070 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 392476 read, time taken: 0.00008240 s. -75% line 294357 read, time taken: 0.08691510 s. -50% line 196238 read, time taken: 0.17316620 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 392476 read, time taken: 0.00005700 s. -75% line 294357 read, time taken: 0.03377610 s. -50% line 196238 read, time taken: 0.06763100 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 100 MB========================= - -Test file of size 100 MB created with 3784596 lines, time used 1.10 seconds. -===============================Built-in readline================================ - -Last line 3784596 read, time taken: 0.34282561 s. -75% line 2838447 read, time taken: 0.25080561 s. -50% line 1892298 read, time taken: 0.15123111 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 3784596 read, time taken: 0.00008080 s. -75% line 2838447 read, time taken: 0.84473163 s. -50% line 1892298 read, time taken: 1.67904916 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 3784596 read, time taken: 0.00008110 s. -75% line 2838447 read, time taken: 0.31592141 s. -50% line 1892298 read, time taken: 0.64531112 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 500 MB========================= - -Test file of size 500 MB created with 18462038 lines, time used 5.47 seconds. -===============================Built-in readline================================ - -Last line 18462038 read, time taken: 1.65052795 s. -75% line 13846528 read, time taken: 1.15872567 s. -50% line 9231019 read, time taken: 0.69172220 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 18462038 read, time taken: 0.00008290 s. -75% line 13846528 read, time taken: 4.07981196 s. -50% line 9231019 read, time taken: 8.28308262 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 18462038 read, time taken: 0.00007250 s. -75% line 13846528 read, time taken: 1.56064874 s. -50% line 9231019 read, time taken: 3.14020898 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 1000 MB========================= - -Test file of size 1000 MB created with 36540934 lines, time used 11.63 seconds. -===============================Built-in readline================================ - -Last line 36540934 read, time taken: 3.14226262 s. -75% line 27405700 read, time taken: 2.52962214 s. -50% line 18270467 read, time taken: 1.50383193 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 36540934 read, time taken: 0.00008620 s. -75% line 27405700 read, time taken: 8.48286770 s. -50% line 18270467 read, time taken: 17.16495857 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 36540934 read, time taken: 0.00007400 s. -75% line 27405700 read, time taken: 3.23107996 s. -50% line 18270467 read, time taken: 6.59040188 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 5000 MB========================= - -Test file of size 5000 MB created with 178466370 lines, time used 68.08 seconds. -===============================Built-in readline================================ - -Last line 178466370 read, time taken: 14.81192763 s. -75% line 133849777 read, time taken: 10.86625818 s. -50% line 89233185 read, time taken: 6.82962298 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 178466370 read, time taken: 0.00107610 s. -75% line 133849777 read, time taken: 41.98991041 s. -50% line 89233185 read, time taken: 88.86566979 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 178466370 read, time taken: 0.00072650 s. -75% line 133849777 read, time taken: 16.51870077 s. -50% line 89233185 read, time taken: 32.09695029 s. -============================End of reverse_readfile============================= diff --git a/benchmark/pypi-7.12-win11.txt b/benchmark/pypi-7.12-win11.txt deleted file mode 100644 index b47fd9150..000000000 --- a/benchmark/pypi-7.12-win11.txt +++ /dev/null @@ -1,145 +0,0 @@ - -Running on OS: Windows-11-10.0.22631-SP0, Python 3.12.5 -==========================Benchmarking file size: 1 MB========================== - -Test file of size 1 MB created with 40757 lines, time used 0.02 seconds. -===============================Built-in readline================================ - -Last line 40757 read, time taken: 0.01602000 s. -75% line 30567 read, time taken: 0.00678060 s. -50% line 20378 read, time taken: 0.00440010 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 40757 read, time taken: 0.00682100 s. -75% line 30567 read, time taken: 0.00861640 s. -50% line 20378 read, time taken: 0.01032880 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 40757 read, time taken: 0.00035980 s. -75% line 30567 read, time taken: 0.01145030 s. -50% line 20378 read, time taken: 0.01462530 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 10 MB========================== - -Test file of size 10 MB created with 392476 lines, time used 0.17 seconds. -===============================Built-in readline================================ - -Last line 392476 read, time taken: 0.08988620 s. -75% line 294357 read, time taken: 0.06274470 s. -50% line 196238 read, time taken: 0.04201110 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 392476 read, time taken: 0.07084520 s. -75% line 294357 read, time taken: 0.08927400 s. -50% line 196238 read, time taken: 0.10541760 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 392476 read, time taken: 0.00015940 s. -75% line 294357 read, time taken: 0.05308200 s. -50% line 196238 read, time taken: 0.09734290 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 100 MB========================= - -Test file of size 100 MB created with 3784596 lines, time used 1.71 seconds. -===============================Built-in readline================================ - -Last line 3784596 read, time taken: 0.88680830 s. -75% line 2838447 read, time taken: 0.66664480 s. -50% line 1892298 read, time taken: 0.44697960 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 3784596 read, time taken: 0.71368880 s. -75% line 2838447 read, time taken: 0.86291260 s. -50% line 1892298 read, time taken: 1.04332270 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 3784596 read, time taken: 0.00015020 s. -75% line 2838447 read, time taken: 0.51161870 s. -50% line 1892298 read, time taken: 0.90967440 s. -============================End of reverse_readfile============================= - -=========================Benchmarking file size: 500 MB========================= - -Test file of size 500 MB created with 18462038 lines, time used 8.34 seconds. -===============================Built-in readline================================ - -Last line 18462038 read, time taken: 4.18576000 s. -75% line 13846528 read, time taken: 3.04948250 s. -50% line 9231019 read, time taken: 2.00662010 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 18462038 read, time taken: 3.52498280 s. -75% line 13846528 read, time taken: 4.23446110 s. -50% line 9231019 read, time taken: 5.16286300 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 18462038 read, time taken: 0.00017130 s. -75% line 13846528 read, time taken: 2.23264890 s. -50% line 9231019 read, time taken: 4.44377030 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 1000 MB========================= - -Test file of size 1000 MB created with 36540934 lines, time used 16.35 seconds. -===============================Built-in readline================================ - -Last line 36540934 read, time taken: 8.15072480 s. -75% line 27405700 read, time taken: 6.11769640 s. -50% line 18270467 read, time taken: 4.03451900 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 36540934 read, time taken: 6.99752910 s. -75% line 27405700 read, time taken: 8.55939080 s. -50% line 18270467 read, time taken: 10.08266420 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 36540934 read, time taken: 0.00017990 s. -75% line 27405700 read, time taken: 4.50390560 s. -50% line 18270467 read, time taken: 8.96961540 s. -============================End of reverse_readfile============================= - -========================Benchmarking file size: 5000 MB========================= - -Test file of size 5000 MB created with 178466370 lines, time used 85.79 seconds. -===============================Built-in readline================================ - -Last line 178466370 read, time taken: 40.56061480 s. -75% line 133849777 read, time taken: 30.29256250 s. -50% line 89233185 read, time taken: 20.17005980 s. -============================End of Built-in readline============================ - -================================reverse_readline================================ - -Last line 178466370 read, time taken: 34.63317840 s. -75% line 133849777 read, time taken: 41.73865510 s. -50% line 89233185 read, time taken: 50.30206010 s. -============================End of reverse_readline============================= - -================================reverse_readfile================================ - -Last line 178466370 read, time taken: 0.00019910 s. -75% line 133849777 read, time taken: 22.48041550 s. -50% line 89233185 read, time taken: 44.89090870 s. -============================End of reverse_readfile=============================