Files
foxhunt/fxt/benches/encryption_performance.rs
jgrusewski 2da5bafc0e refactor: rename tli→fxt, delete legacy scripts/RunPod/deploy artifacts
- Rename tli/ directory to fxt/, update package + binary name to "fxt"
- Replace all `use tli::` → `use fxt::` across 52 Rust files
- Update build.rs proto paths (tli/proto → fxt/proto) in 6 services
- Update Dockerfiles, CI workflows, deploy.sh for new paths
- Delete ~170 legacy shell scripts (kept 15 essential ones)
- Delete RunPod Python client (runpod/), tests (tests/runpod/)
- Delete foxhunt-deploy crate (RunPod-only deployment tool)
- Delete terraform/runpod/ (moved to Scaleway)
- Delete ML Python hyperopt scripts (replaced by Rust Argmin PSO)
- Delete .gitlab-ci.yml (using GitHub + Gitea)
- Remove foxhunt-deploy from workspace members

504 files changed, -74,355 lines of legacy code removed.
Workspace compiles clean (0 errors, 0 warnings).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 10:32:21 +01:00

88 lines
2.7 KiB
Rust

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use fxt::auth::token_manager::{FileTokenStorage, TokenStorage};
fn create_test_storage() -> FileTokenStorage {
// Use default directory - benchmark will measure real-world performance
FileTokenStorage::new().unwrap()
}
fn bench_store_token_encrypted(c: &mut Criterion) {
c.bench_function("store_token_encrypted", |b| {
let storage = create_test_storage();
let token = "test_token_12345678901234567890123456789012345678901234567890";
b.iter(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
storage.store_access_token(black_box(token)).await.unwrap();
});
});
});
}
fn bench_retrieve_token_encrypted(c: &mut Criterion) {
c.bench_function("retrieve_token_encrypted", |b| {
let storage = create_test_storage();
let token = "test_token_12345678901234567890123456789012345678901234567890";
// Store token first
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
storage.store_access_token(token).await.unwrap();
});
b.iter(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
black_box(storage.get_access_token().await.unwrap());
});
});
});
}
fn bench_roundtrip_encrypted(c: &mut Criterion) {
c.bench_function("roundtrip_encrypted", |b| {
let token = "test_token_12345678901234567890123456789012345678901234567890";
b.iter(|| {
let storage = create_test_storage();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
storage.store_access_token(black_box(token)).await.unwrap();
black_box(storage.get_access_token().await.unwrap());
});
});
});
}
fn bench_key_derivation(c: &mut Criterion) {
use fxt::auth::KeyManager;
c.bench_function("key_derivation_first_call", |b| {
b.iter(|| {
let mut manager = KeyManager::new();
black_box(manager.derive_key().unwrap());
});
});
// Benchmark cached key derivation
c.bench_function("key_derivation_cached", |b| {
let mut manager = KeyManager::new();
// Prime the cache
manager.derive_key().unwrap();
b.iter(|| {
black_box(manager.derive_key().unwrap());
});
});
}
criterion_group!(
benches,
bench_store_token_encrypted,
bench_retrieve_token_encrypted,
bench_roundtrip_encrypted,
bench_key_derivation
);
criterion_main!(benches);