create a not-exactly-a-benchmark

This commit is contained in:
Kyle Kelley
2024-04-04 16:48:34 -07:00
parent 7ddf0467a5
commit 9705e26cff

View File

@@ -164,6 +164,47 @@ mod test {
}
}
#[gpui::test]
async fn test_ollama_embedding_not_exactly_a_benchmark(executor: BackgroundExecutor) {
executor.allow_parking();
let client = Arc::new(HttpClientWithUrl::new("http://localhost:11434/"));
let provider =
OllamaEmbeddingProvider::new(client.into(), EmbeddingModel::OllamaNomicEmbedText);
let t_nomic = std::time::Instant::now();
for i in 0..100 {
let embedding = provider
.get_embedding(format!("Hello, world! {}", i))
.await
.unwrap();
match embedding {
Embedding::OllamaNomicEmbedText(e) => assert_eq!(e.len(), EMBEDDING_SIZE_TINY),
_ => panic!("Invalid embedding size"),
}
}
dbg!(t_nomic.elapsed());
let client = Arc::new(HttpClientWithUrl::new("http://localhost:11434/"));
let provider =
OllamaEmbeddingProvider::new(client.into(), EmbeddingModel::OllamaMxbaiEmbedLarge);
let t_mxbai = std::time::Instant::now();
for i in 0..100 {
let embedding = provider
.get_embedding(format!("Hello, world! {}", i))
.await
.unwrap();
match embedding {
Embedding::OllamaMxbaiEmbedLarge(e) => assert_eq!(e.len(), EMBEDDING_SIZE_XSMALL),
_ => panic!("Invalid embedding size"),
}
}
dbg!(t_mxbai.elapsed());
}
#[gpui::test]
fn test_normalize_embedding() {
// Create an vector of size EMBEDDING_SIZE_TINY with all values set to 1.0