|
1 | 1 | //! Comprehensive Word operation benchmarks |
2 | 2 | //! |
3 | 3 | //! This module benchmarks all Word operations implemented in the library |
4 | | -//! with a focus on type conversions, serialization, and lexicographic ordering. |
| 4 | +//! with a focus on type conversions, serialization, and ordering. |
5 | 5 | //! |
6 | 6 | //! # Organization |
7 | 7 | //! |
8 | 8 | //! The benchmarks are organized by: |
9 | 9 | //! 1. Word creation and basic operations |
10 | 10 | //! 2. Type conversions (bool, u8, u16, u32, u64) |
11 | 11 | //! 3. Serialization and deserialization |
12 | | -//! 4. Lexicographic ordering |
| 12 | +//! 4. Ordering (lexicographic) |
13 | 13 | //! 5. Batch operations |
14 | 14 | //! |
15 | 15 | //! # Adding New Word Benchmarks |
|
22 | 22 |
|
23 | 23 | use criterion::{Criterion, criterion_group, criterion_main}; |
24 | 24 | // Import Word modules |
25 | | -use miden_crypto::{Felt, LexicographicWord, Word}; |
| 25 | +use miden_crypto::{Felt, Word}; |
26 | 26 |
|
27 | 27 | // Import common utilities |
28 | 28 | mod common; |
@@ -198,82 +198,42 @@ benchmark_with_setup! { |
198 | 198 | }, |
199 | 199 | } |
200 | 200 |
|
201 | | -// === Lexicographic Ordering Benchmarks === |
| 201 | +// === Ordering Benchmarks === |
202 | 202 |
|
203 | | -// Lexicographic word creation |
204 | | -benchmark_with_setup! { |
205 | | - word_lexicographic_new, |
206 | | - DEFAULT_MEASUREMENT_TIME, |
207 | | - DEFAULT_SAMPLE_SIZE, |
208 | | - "new", |
209 | | - || {}, |
210 | | - |b: &mut criterion::Bencher| { |
211 | | - b.iter(|| { |
212 | | - for word in &TEST_WORDS { |
213 | | - let _lex_word = LexicographicWord::new(*word); |
214 | | - } |
215 | | - }) |
216 | | - }, |
217 | | -} |
218 | | - |
219 | | -// Lexicographic word access |
220 | | -benchmark_with_setup_data! { |
221 | | - word_lexicographic_access, |
222 | | - DEFAULT_MEASUREMENT_TIME, |
223 | | - DEFAULT_SAMPLE_SIZE, |
224 | | - "inner_access", |
225 | | - || { |
226 | | - let lex_words: Vec<LexicographicWord> = |
227 | | - TEST_WORDS.iter().map(|w| LexicographicWord::new(*w)).collect(); |
228 | | - lex_words |
229 | | - }, |
230 | | - |b: &mut criterion::Bencher, lex_words: &Vec<LexicographicWord>| { |
231 | | - b.iter(|| { |
232 | | - for lex_word in lex_words { |
233 | | - let _inner = lex_word.inner(); |
234 | | - } |
235 | | - }) |
236 | | - }, |
237 | | -} |
238 | | - |
239 | | -// Lexicographic ordering comparisons |
| 203 | +// Word ordering comparisons (lexicographic) |
240 | 204 | benchmark_with_setup_data! { |
241 | | - word_lexicographic_ordering, |
| 205 | + word_cmp, |
242 | 206 | DEFAULT_MEASUREMENT_TIME, |
243 | 207 | DEFAULT_SAMPLE_SIZE, |
244 | | - "partial_cmp", |
| 208 | + "cmp", |
245 | 209 | || { |
246 | | - let lex_words: Vec<LexicographicWord> = |
247 | | - TEST_WORDS.iter().map(|w| LexicographicWord::new(*w)).collect(); |
248 | | - lex_words |
| 210 | + TEST_WORDS.to_vec() |
249 | 211 | }, |
250 | | - |b: &mut criterion::Bencher, lex_words: &Vec<LexicographicWord>| { |
| 212 | + |b: &mut criterion::Bencher, words: &Vec<Word>| { |
251 | 213 | b.iter(|| { |
252 | | - for i in 0..lex_words.len() { |
253 | | - for j in i..lex_words.len() { |
254 | | - let _result = lex_words[i].partial_cmp(&lex_words[j]); |
| 214 | + for i in 0..words.len() { |
| 215 | + for j in i..words.len() { |
| 216 | + let _result = words[i].cmp(&words[j]); |
255 | 217 | } |
256 | 218 | } |
257 | 219 | }) |
258 | 220 | }, |
259 | 221 | } |
260 | 222 |
|
261 | | -// Lexicographic equality comparison |
| 223 | +// Word equality comparison |
262 | 224 | benchmark_with_setup_data! { |
263 | | - word_lexicographic_eq, |
| 225 | + word_eq, |
264 | 226 | DEFAULT_MEASUREMENT_TIME, |
265 | 227 | DEFAULT_SAMPLE_SIZE, |
266 | 228 | "eq", |
267 | 229 | || { |
268 | | - let lex_words: Vec<LexicographicWord> = |
269 | | - TEST_WORDS.iter().map(|w| LexicographicWord::new(*w)).collect(); |
270 | | - lex_words |
| 230 | + TEST_WORDS.to_vec() |
271 | 231 | }, |
272 | | - |b: &mut criterion::Bencher, lex_words: &Vec<LexicographicWord>| { |
| 232 | + |b: &mut criterion::Bencher, words: &Vec<Word>| { |
273 | 233 | b.iter(|| { |
274 | | - for i in 0..lex_words.len() { |
275 | | - for j in 0..lex_words.len() { |
276 | | - let _result = lex_words[i] == lex_words[j]; |
| 234 | + for i in 0..words.len() { |
| 235 | + for j in 0..words.len() { |
| 236 | + let _result = words[i] == words[j]; |
277 | 237 | } |
278 | 238 | } |
279 | 239 | }) |
@@ -321,11 +281,9 @@ criterion_group!( |
321 | 281 | // Serialization benchmarks |
322 | 282 | word_to_hex, |
323 | 283 | word_to_vec, |
324 | | - // Lexicographic ordering benchmarks |
325 | | - word_lexicographic_new, |
326 | | - word_lexicographic_access, |
327 | | - word_lexicographic_ordering, |
328 | | - word_lexicographic_eq, |
| 284 | + // Ordering benchmarks |
| 285 | + word_cmp, |
| 286 | + word_eq, |
329 | 287 | // Batch operations benchmarks |
330 | 288 | word_batch_elements, |
331 | 289 | ); |
|
0 commit comments