|
Zip and Skip Tries
|
Classes | |
| class | DataType |
| class | FitLine |
Functions | |
| get_dpi (bool savefig) | |
| 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=[]) |
| Path | get_file (str method_name, DataType data_type) |
| plot (str figure_name, bool save, str ylabel, str xlabel, str|None legend_loc='best') | |
| tuple[list[int], list[int], list[int], list[float]] | load_data (str method_name, DataType data_type, int cutoff=0) |
| tuple[tuple[int], tuple[float]] | get_data_point (str method_name, DataType data_type, int index, int cutoff=0) |
| 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, int index, int cutoff=0, 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) | |
| compare_search_data (bool savefig) | |
Variables | |
| HOSTNAME = socket.gethostname() | |
| DATA_DIRECTORY = Path('data-genetic') | |
| str | CONSTRUCTION_FILENAME = 'construction-data' |
| str | REMOVAL_FILENAME = 'removal-data' |
| str | SEARCH_FILENAME = 'search-data' |
| FIGURE_DIRECTORY = Path('figures') | |
| exist_ok | |
| list | OKABE_COLORS = ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] |
| color | |
| float | POINT_SIZE = 0.1 |
| bool | savefig = False |
Plotting script for genetic benchmark data. This script generates plots from benchmark data collected using genetic_benchmark.cu. It creates various plots comparing the performance of different trie implementations on genetic data from the ABC-HuMi dataset, focusing on construction and search times. The script reads CSV files from the data-genetic directory and generates plots in the figures directory. It supports plotting construction time and search time against different parameters (number of keys, total key length, LCP length). The plots include trend lines with log-log regression to analyze asymptotic behavior.
| plot_genetic.add_data_point_to_plot | ( | str | method_name, |
| DataType | data_type, | ||
| int | index, | ||
| int | cutoff = 0, |
||
| 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, 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)
index: Which parameter to plot against (0 for n, 1 for m, 2 for l)
cutoff: Filter value for the parallel cutoff parameter
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', 'L')
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 302 of file plot_genetic.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 82 of file plot_genetic.py.
| plot_genetic.compare_construction_data | ( | bool | savefig | ) |
Create plots comparing construction time for different implementations.
Generates three plots:
1. Construction time vs. number of keys (n)
2. Construction time vs. total key length (N)
3. Construction time vs. total LCP length (L)
Args:
savefig: If True, save the figures to files; if False, display them
Definition at line 344 of file plot_genetic.py.
| plot_genetic.compare_search_data | ( | bool | savefig | ) |
Create plots comparing search time for different implementations.
Generates two plots:
1. Search time vs. number of keys (n)
2. Search time vs. LCP length (ℓ)
Args:
savefig: If True, save the figures to files; if False, display them
Definition at line 416 of file plot_genetic.py.
| FitLine | None plot_genetic.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 107 of file plot_genetic.py.
| tuple[tuple[int], tuple[float]] plot_genetic.get_data_point | ( | str | method_name, |
| DataType | data_type, | ||
| int | index, | ||
| int | cutoff = 0 |
||
| ) |
Extract a specific data series from the benchmark data.
Loads data and extracts a specific parameter (based on index) and the corresponding times.
Args:
method_name: Name of the method/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
index: Which parameter to extract (0 for n, 1 for m, 2 for l)
cutoff: Filter value for the parallel cutoff parameter
Returns:
Tuple of (x values, y values) sorted by x, where x is the selected parameter and y is elapsed time
Definition at line 229 of file plot_genetic.py.
| plot_genetic.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 52 of file plot_genetic.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 152 of file plot_genetic.py.
| tuple[list[int], list[int], list[int], list[float]] plot_genetic.load_data | ( | str | method_name, |
| DataType | data_type, | ||
| int | cutoff = 0 |
||
| ) |
Load benchmark data from a CSV file.
Reads benchmark data for a specific method and data type, filtering by cutoff value.
Args:
method_name: Name of the method/implementation being benchmarked
data_type: Type of benchmark data (construction, removal, or search)
cutoff: Filter value for the parallel cutoff parameter
Returns:
Tuple containing lists of (n values, m values, l values, elapsed times)
where n is number of keys, m is key length, l is LCP length, and elapsed times are in nanoseconds
Definition at line 195 of file plot_genetic.py.
| tuple[list[int], list[float]] plot_genetic.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 248 of file plot_genetic.py.
| plot_genetic.plot | ( | str | figure_name, |
| bool | save, | ||
| str | ylabel, | ||
| str | xlabel, | ||
| str | None | 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
legend_loc: Position for the legend (e.g., 'best', 'upper left', etc.)
Definition at line 170 of file plot_genetic.py.
| plot_genetic.color |
Definition at line 47 of file plot_genetic.py.
| str plot_genetic.CONSTRUCTION_FILENAME = 'construction-data' |
Definition at line 37 of file plot_genetic.py.
| plot_genetic.DATA_DIRECTORY = Path('data-genetic') |
Definition at line 36 of file plot_genetic.py.
| plot_genetic.exist_ok |
Definition at line 43 of file plot_genetic.py.
| plot_genetic.FIGURE_DIRECTORY = Path('figures') |
Definition at line 42 of file plot_genetic.py.
| plot_genetic.HOSTNAME = socket.gethostname() |
Definition at line 33 of file plot_genetic.py.
| list plot_genetic.OKABE_COLORS = ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] |
Definition at line 46 of file plot_genetic.py.
| float plot_genetic.POINT_SIZE = 0.1 |
Definition at line 50 of file plot_genetic.py.
Definition at line 38 of file plot_genetic.py.
Definition at line 475 of file plot_genetic.py.
| str plot_genetic.SEARCH_FILENAME = 'search-data' |
Definition at line 39 of file plot_genetic.py.