|
Zip and Skip Tries
|
Classes | |
| class | DataType |
| class | FitLine |
Functions | |
| get_dpi (bool savefig) | |
| Path | get_file (str method_name, DataType data_type) |
| int | binary_search (list[int] x, int key) |
| FitLine|None | fit_log_line (list[int] x, list[float] y, int skip_until=0, bool all_points=False, list[int] add_next=[]) |
| plot (str figure_name, bool save, str ylabel, str xlabel='Num nodes(n)', str legend_loc='best') | |
| dict[tuple[int, int, int], tuple[int, int]] | load_agg_data (str data_structure, DataType data_type) |
| tuple[tuple[int], tuple[float]] | load_data (str data_structure, DataType data_type, tuple[int, int, int] match) |
| tuple[list[int], list[float]] | moving_average (list[int] x, list[float] y, float window=1.9) |
| add_data_point_to_plot (str method_name, DataType data_type, tuple[int, int, int] match, int skip_until=0, str fitlabel='', int max_value=-1, float markersize=POINT_SIZE, bool draw_best_fit=True, str label='') | |
| compare_construction_data (bool savefig=False) | |
| compare_search_data (bool savefig=False) | |
Variables | |
| DATA_DIRECTORY = Path('data-synthetic') | |
| HOSTNAME = socket.gethostname() | |
| int | MAX_WORD_LENGTH = 2**22 |
| str | CONSTRUCTION_FILENAME = 'construction-data' |
| str | REMOVAL_FILENAME = 'removal-data' |
| str | SEARCH_FILENAME = 'search-data' |
| int | START_PARALLEL = 1 |
| FIGURE_DIRECTORY = Path('figures') | |
| parents | |
| True | |
| exist_ok | |
| list | OKABE_COLORS = ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] |
| color | |
| int | POINT_SIZE = 1 |
| bool | savefig = False |
Plotting script for synthetic benchmark data. This script generates plots from benchmark data collected using synthetic_benchmark.cu. It creates various plots comparing the performance of different trie implementations on synthetic data with controlled properties, focusing on construction and search times. The script reads CSV files from the data-synthetic directory and generates plots in the figures directory. It supports plotting construction time and search time against different parameters (number of keys, key length, LCP length). The plots include trend lines with log-log regression to analyze asymptotic behavior.
| plot_synthetic.add_data_point_to_plot | ( | str | method_name, |
| DataType | data_type, | ||
| tuple[int, int, int] | match, | ||
| int | skip_until = 0, |
||
| str | fitlabel = '', |
||
| int | max_value = -1, |
||
| float | markersize = POINT_SIZE, |
||
| bool | draw_best_fit = True, |
||
| str | label = '' |
||
| ) |
Add a data series to the current plot with optional trend line.
Loads data for a specific method and parameter combination, applies smoothing, and adds it to the plot.
Optionally fits and adds a trend line with equation and R² value in the legend.
Args:
method_name: Name of the method/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
match: Tuple of (n, m, l) where -1 indicates the parameter to vary
skip_until: Skip data points with x values less than this threshold for trend line fitting
fitlabel: Label to use in the trend line equation (e.g., 'n', 'm', '\\ell')
max_value: Maximum x value to include (-1 for no limit)
markersize: Size of the markers for data points
draw_best_fit: If True, fit and draw a trend line; if False, only plot data points
label: Custom label for the data series (defaults to method_name if empty)
Definition at line 329 of file plot_synthetic.py.
Perform binary search to find the insertion point for key in a sorted list.
Used to find the index where data points should be skipped when fitting trend lines.
Args:
x: Sorted list of integers to search in
key: Value to find the insertion point for
Returns:
Index where key should be inserted to maintain sorted order
Definition at line 102 of file plot_synthetic.py.
Create plots comparing construction time for different implementations.
Generates two plots:
1. Construction time vs. LCP length (ℓ)
2. Construction time vs. key length (m)
Some plots are commented out in the code but can be uncommented if needed.
Args:
savefig: If True, save the figures to files; if False, display them
Definition at line 370 of file plot_synthetic.py.
Create plots comparing search time for different implementations.
Generates two plots:
1. Search time vs. key length (m)
2. Search time vs. LCP length (ℓ)
Some plots are commented out in the code but can be uncommented if needed.
Args:
savefig: If True, save the figures to files; if False, display them
Definition at line 422 of file plot_synthetic.py.
| FitLine | None plot_synthetic.fit_log_line | ( | list[int] | x, |
| list[float] | y, | ||
| int | skip_until = 0, |
||
| bool | all_points = False, |
||
| list[int] | add_next = [] |
||
| ) |
Fit a line to log-transformed data points for trend line analysis.
Performs linear regression on log2-transformed data to analyze asymptotic behavior.
Can skip initial data points to focus on asymptotic behavior at scale.
Args:
x: List of x-coordinates (typically problem sizes)
y: List of y-coordinates (typically running times)
skip_until: Skip data points with x values less than this threshold
all_points: If True, include all points in the result; if False, only include endpoints
add_next: Additional x values to extrapolate to
Returns:
A FitLine object containing the fitted line parameters, or None if fitting failed
Definition at line 129 of file plot_synthetic.py.
| plot_synthetic.get_dpi | ( | bool | savefig | ) |
Set the DPI (dots per inch) for figures based on whether they will be saved or displayed.
Args:
savefig: If True, use higher DPI (600) for saved figures, otherwise use lower DPI (300) for display
Definition at line 46 of file plot_synthetic.py.
Get the file path for benchmark data based on method name and data type.
Args:
method_name: Name of the method/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
Returns:
Path object pointing to the CSV file containing the benchmark data
Definition at line 69 of file plot_synthetic.py.
| dict[tuple[int, int, int], tuple[int, int]] plot_synthetic.load_agg_data | ( | str | data_structure, |
| DataType | data_type | ||
| ) |
Load and aggregate benchmark data from a CSV file.
Reads benchmark data for a specific method and data type, aggregating duplicate entries.
Args:
data_structure: Name of the data structure/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
Returns:
Dictionary mapping (n, m, l) tuples to (total_time, repetition_count) tuples,
where n is number of keys, m is key length, and l is LCP length
Definition at line 201 of file plot_synthetic.py.
| tuple[tuple[int], tuple[float]] plot_synthetic.load_data | ( | str | data_structure, |
| DataType | data_type, | ||
| tuple[int, int, int] | match | ||
| ) |
Extract a specific data series from the benchmark data.
Loads aggregated data and extracts a specific parameter series based on the match tuple.
Args:
data_structure: Name of the data structure/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
match: Tuple of (n, m, l) where -1 indicates the parameter to vary
For example, (-1, 1024, 1024) means vary n with m=1024 and l=1024
Returns:
Tuple of (x values, y values) sorted by x, where x is the selected parameter and y is elapsed time
Definition at line 237 of file plot_synthetic.py.
| tuple[list[int], list[float]] plot_synthetic.moving_average | ( | list[int] | x, |
| list[float] | y, | ||
| float | window = 1.9 |
||
| ) |
Apply a moving average smoothing to data points.
First consolidates duplicate x values, then applies a geometric window smoothing
to reduce noise in the data while preserving trends.
Args:
x: List of x-coordinates
y: List of y-coordinates
window: Window size factor (points within x/window to x*window are averaged)
Returns:
Tuple of (smoothed x values, smoothed y values)
Definition at line 273 of file plot_synthetic.py.
| plot_synthetic.plot | ( | str | figure_name, |
| bool | save, | ||
| str | ylabel, | ||
| str | xlabel = 'Num nodes (n)', |
||
| str | legend_loc = 'best' |
||
| ) |
Finalize and display or save a plot.
Adds labels, legend, and either displays the plot or saves it to a file.
Args:
figure_name: Base name for the saved figure file (without extension)
save: If True, save the figure to a file; if False, display it
ylabel: Label for the y-axis
xlabel: Label for the x-axis (defaults to 'Num nodes (n)')
legend_loc: Position for the legend (defaults to 'best')
Definition at line 176 of file plot_synthetic.py.
| plot_synthetic.color |
Definition at line 43 of file plot_synthetic.py.
| str plot_synthetic.CONSTRUCTION_FILENAME = 'construction-data' |
Definition at line 34 of file plot_synthetic.py.
| plot_synthetic.DATA_DIRECTORY = Path('data-synthetic') |
Definition at line 31 of file plot_synthetic.py.
| plot_synthetic.exist_ok |
Definition at line 40 of file plot_synthetic.py.
| plot_synthetic.FIGURE_DIRECTORY = Path('figures') |
Definition at line 39 of file plot_synthetic.py.
| plot_synthetic.HOSTNAME = socket.gethostname() |
Definition at line 32 of file plot_synthetic.py.
| int plot_synthetic.MAX_WORD_LENGTH = 2**22 |
Definition at line 33 of file plot_synthetic.py.
| list plot_synthetic.OKABE_COLORS = ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] |
Definition at line 42 of file plot_synthetic.py.
| plot_synthetic.parents |
Definition at line 40 of file plot_synthetic.py.
| int plot_synthetic.POINT_SIZE = 1 |
Definition at line 56 of file plot_synthetic.py.
Definition at line 35 of file plot_synthetic.py.
Definition at line 473 of file plot_synthetic.py.
| str plot_synthetic.SEARCH_FILENAME = 'search-data' |
Definition at line 36 of file plot_synthetic.py.
| int plot_synthetic.START_PARALLEL = 1 |
Definition at line 37 of file plot_synthetic.py.
| plot_synthetic.True |
Definition at line 40 of file plot_synthetic.py.