BenchmarkTestData

Struct BenchmarkTestData 

Source
pub struct BenchmarkTestData {
    pub texts: Vec<&'static str>,
    pub semantic_pairs: Vec<(usize, usize, f32)>,
}
Expand description

Test data for benchmarking

Fields§

§texts: Vec<&'static str>§semantic_pairs: Vec<(usize, usize, f32)>

Implementations§

Source§

impl BenchmarkTestData

Source

pub fn new_default() -> Self

Get default test data for benchmarking

Examples found in repository?
examples/benchmark_hash.rs (line 13)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    println!("🔥 Manx Embedding Provider Benchmarks");
9    println!("=====================================\n");
10
11    // Test different hash dimensions
12    let dimensions = vec![128, 256, 384, 512, 768];
13    let test_data = BenchmarkTestData::new_default();
14    let extended_data = BenchmarkTestData::extended();
15
16    println!("📊 Testing Hash Provider with Different Dimensions");
17    println!(
18        "Test Data: {} texts with {} similarity pairs\n",
19        test_data.texts.len(),
20        test_data.semantic_pairs.len()
21    );
22
23    let mut results = Vec::new();
24
25    for dim in &dimensions {
26        let provider = HashProvider::new(*dim);
27        let result = benchmark_provider(&provider, &test_data).await?;
28        results.push(result);
29    }
30
31    print_benchmark_results(&results);
32
33    println!("\n📈 Extended Dataset Benchmark (Hash-384)");
34    println!(
35        "Extended Data: {} texts with {} similarity pairs\n",
36        extended_data.texts.len(),
37        extended_data.semantic_pairs.len()
38    );
39
40    let provider_384 = HashProvider::new(384);
41    let extended_result = benchmark_provider(&provider_384, &extended_data).await?;
42    print_benchmark_results(&[extended_result]);
43
44    println!("\n✅ Benchmark Complete!");
45    println!("💡 Next: Compare with ONNX-based embeddings for quality improvements");
46
47    Ok(())
48}
Source

pub fn extended() -> Self

Get extended test data for more comprehensive benchmarking

Examples found in repository?
examples/benchmark_hash.rs (line 14)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    println!("🔥 Manx Embedding Provider Benchmarks");
9    println!("=====================================\n");
10
11    // Test different hash dimensions
12    let dimensions = vec![128, 256, 384, 512, 768];
13    let test_data = BenchmarkTestData::new_default();
14    let extended_data = BenchmarkTestData::extended();
15
16    println!("📊 Testing Hash Provider with Different Dimensions");
17    println!(
18        "Test Data: {} texts with {} similarity pairs\n",
19        test_data.texts.len(),
20        test_data.semantic_pairs.len()
21    );
22
23    let mut results = Vec::new();
24
25    for dim in &dimensions {
26        let provider = HashProvider::new(*dim);
27        let result = benchmark_provider(&provider, &test_data).await?;
28        results.push(result);
29    }
30
31    print_benchmark_results(&results);
32
33    println!("\n📈 Extended Dataset Benchmark (Hash-384)");
34    println!(
35        "Extended Data: {} texts with {} similarity pairs\n",
36        extended_data.texts.len(),
37        extended_data.semantic_pairs.len()
38    );
39
40    let provider_384 = HashProvider::new(384);
41    let extended_result = benchmark_provider(&provider_384, &extended_data).await?;
42    print_benchmark_results(&[extended_result]);
43
44    println!("\n✅ Benchmark Complete!");
45    println!("💡 Next: Compare with ONNX-based embeddings for quality improvements");
46
47    Ok(())
48}
More examples
Hide additional examples
examples/benchmark_onnx_vs_hash.rs (line 24)
13async fn main() -> Result<()> {
14    // Initialize logging to see what's happening
15    env_logger::builder()
16        .filter_level(log::LevelFilter::Info)
17        .init();
18
19    println!("🚀 Manx Embedding Provider Performance Comparison");
20    println!("================================================");
21    println!("Comparing Hash vs ONNX-based embeddings\n");
22
23    // Test data for comparison
24    let test_data = BenchmarkTestData::extended();
25    println!("📊 Test Dataset:");
26    println!(
27        "   {} texts with {} semantic similarity pairs",
28        test_data.texts.len(),
29        test_data.semantic_pairs.len()
30    );
31
32    println!("\n📋 Sample texts:");
33    for (i, text) in test_data.texts.iter().take(3).enumerate() {
34        println!("   {}. {}", i + 1, text);
35    }
36    println!("   ... and {} more", test_data.texts.len() - 3);
37
38    println!("\n{}", "=".repeat(60));
39
40    // Benchmark 1: Hash Provider (current baseline)
41    println!("\n🔧 PHASE 1: Hash-based Embeddings (Baseline)");
42    println!("---------------------------------------------");
43
44    let hash_provider = HashProvider::new(384);
45    let hash_result = benchmark_provider(&hash_provider, &test_data).await?;
46
47    print_benchmark_results(std::slice::from_ref(&hash_result));
48
49    // Benchmark 2: ONNX Provider (if available)
50    println!("\n🤖 PHASE 2: ONNX-based Embeddings (Testing)");
51    println!("--------------------------------------------");
52
53    // Check if we need to download the model
54    let model_name = "sentence-transformers/all-MiniLM-L6-v2";
55    println!("📦 Checking for ONNX model: {}", model_name);
56
57    // Note: In a real implementation, we'd download the model here
58    // For now, we'll create a simulation to show what the comparison would look like
59    println!("⚠️  ONNX model download not implemented in this demo");
60    println!("    In production, this would:");
61    println!("    1. Download {} from HuggingFace", model_name);
62    println!("    2. Convert to ONNX format if needed");
63    println!("    3. Load tokenizer and model files");
64    println!("    4. Initialize ONNX Runtime session");
65
66    // Simulate what ONNX results would look like based on research
67    simulate_onnx_comparison(&hash_result).await?;
68
69    println!("\n{}", "=".repeat(60));
70    println!("\n📈 SUMMARY & RECOMMENDATIONS");
71    println!("============================");
72
73    print_recommendations(&hash_result);
74
75    println!("\n✅ Benchmark Complete!");
76    println!("\n💡 To enable real ONNX testing:");
77    println!("   1. Implement model download from HuggingFace");
78    println!("   2. Add ONNX model file handling");
79    println!(
80        "   3. Test with: cargo run --example benchmark_onnx_vs_hash --features onnx-embeddings"
81    );
82
83    Ok(())
84}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,