The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(rust): assert merge cost scales linearly instead of a wall-clock bound
Yujong Leee850232f0208
diff --git a/litellm-rust/.config/nextest.toml b/litellm-rust/.config/nextest.tomldeleted file mode 100644index 1762a151573..00000000000--- a/litellm-rust/.config/nextest.toml+++ /dev/null@@ -1,3 +0,0 @@-[[profile.default.overrides]]-filter = "test(long_repeated_runs_stay_cheap)"-threads-required = "num-cpus"diff --git a/litellm-rust/crates/token-counter/src/tiktoken.rs b/litellm-rust/crates/token-counter/src/tiktoken.rsindex c479ae01be9..7a9e71ed587 100644--- a/litellm-rust/crates/token-counter/src/tiktoken.rs+++ b/litellm-rust/crates/token-counter/src/tiktoken.rs@@ -195,14 +195,21 @@ mod tests {}#[test]- fn long_repeated_runs_stay_cheap() {+ fn long_repeated_runs_cost_close_to_linear() {let ranks = ranks();let mut scratch = MergeScratch::default();- let piece = vec![b' '; 1 << 20];- let started = std::time::Instant::now();- let count = ranks.count_piece(&piece, &mut scratch);- assert!(count > 0);- assert!(started.elapsed().as_secs() < 5, "{:?}", started.elapsed());+ let mut time = |len: usize| {+ let piece = vec![b' '; len];+ let started = std::time::Instant::now();+ assert!(ranks.count_piece(&piece, &mut scratch) > 0);+ started.elapsed()+ };+ let small = (0..3).map(|_| time(1 << 14)).min().unwrap();+ let large = time(1 << 18);+ assert!(+ large < small * 64,+ "{small:?} for 2^14 bytes, {large:?} for 2^18"+ );}#[test]