...
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use tst::TST;
|
||||
use std::time::Instant;
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() -> Result<(), tst::Error> {
|
||||
// Create a temporary directory for the database
|
||||
|
@@ -2,6 +2,22 @@ use tst::TST;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::io::{self, Write};
|
||||
|
||||
// Function to generate a test value of specified size
|
||||
fn generate_test_value(index: usize, size: usize) -> Vec<u8> {
|
||||
let base_value = format!("val{:08}", index);
|
||||
let mut value = Vec::with_capacity(size);
|
||||
|
||||
// Fill with repeating pattern to reach desired size
|
||||
while value.len() < size {
|
||||
value.extend_from_slice(base_value.as_bytes());
|
||||
}
|
||||
|
||||
// Truncate to exact size
|
||||
value.truncate(size);
|
||||
|
||||
value
|
||||
}
|
||||
|
||||
// Number of records to insert
|
||||
const TOTAL_RECORDS: usize = 100_000;
|
||||
// How often to report progress (every X records)
|
||||
@@ -36,8 +52,8 @@ fn main() -> Result<(), tst::Error> {
|
||||
// Insert records and track progress
|
||||
for i in 0..TOTAL_RECORDS {
|
||||
let key = format!("key:{:08}", i);
|
||||
// Use smaller values to avoid exceeding OurDB's size limit
|
||||
let value = format!("val{}", i).into_bytes();
|
||||
// Generate a 100-byte value
|
||||
let value = generate_test_value(i, 100);
|
||||
|
||||
// Time the insertion of every Nth record for performance sampling
|
||||
if i % PERFORMANCE_SAMPLE_SIZE == 0 {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
use tst::TST;
|
||||
use std::time::Instant;
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() -> Result<(), tst::Error> {
|
||||
// Create a temporary directory for the database
|
||||
|
Reference in New Issue
Block a user