@@ -233,12 +233,6 @@ mod tests {
233
233
use opentelemetry:: logs:: AnyValue ;
234
234
use opentelemetry:: Key ;
235
235
236
- #[ cfg( feature = "memory-profiling" ) ]
237
- use crate :: testing:: global_allocator;
238
-
239
- #[ cfg( feature = "memory-profiling" ) ]
240
- use jemalloc_ctl:: { epoch, stats} ;
241
-
242
236
/// A struct to hold a key-value pair and implement `Default`.
243
237
#[ derive( Clone , Debug , PartialEq ) ]
244
238
struct KeyValuePair ( Key , AnyValue ) ;
@@ -338,58 +332,4 @@ mod tests {
338
332
collection. push ( 15 ) ;
339
333
assert ! ( collection. contains( & 15 ) ) ;
340
334
}
341
-
342
- #[ cfg( feature = "memory-profiling" ) ]
343
- #[ test]
344
- fn test_memory_allocation_string ( ) {
345
- // Reset jemalloc epoch to refresh stats
346
- let e = epoch:: mib ( ) . unwrap ( ) ;
347
- e. advance ( ) . unwrap ( ) ;
348
-
349
- // Get memory stats before the code block
350
- let allocated_before = stats:: allocated:: read ( ) . unwrap ( ) ;
351
-
352
- // Code block to measure: Allocate a large string
353
- let large_string: String = "a" . repeat ( 100_000 ) ;
354
-
355
- // Refresh jemalloc stats
356
- e. advance ( ) . unwrap ( ) ;
357
-
358
- // Get memory stats after the code block
359
- let allocated_after = stats:: allocated:: read ( ) . unwrap ( ) ;
360
-
361
- // Calculate the difference
362
- let allocated_diff = allocated_after - allocated_before;
363
-
364
- // Assert or print the difference
365
- println ! ( "Memory allocated for String: {} bytes" , allocated_diff) ;
366
- assert ! ( allocated_diff > 0 ) ;
367
- }
368
-
369
- #[ cfg( feature = "memory-profiling" ) ]
370
- #[ test]
371
- fn test_memory_allocation_int ( ) {
372
- // Reset jemalloc epoch to refresh stats
373
- let e = epoch:: mib ( ) . unwrap ( ) ;
374
- e. advance ( ) . unwrap ( ) ;
375
-
376
- // Get memory stats before the code block
377
- let allocated_before = stats:: allocated:: read ( ) . unwrap ( ) ;
378
-
379
- // Code block to measure: Allocate a vector of integers
380
- let vec: Vec < i32 > = ( 0 ..100_000 ) . collect ( ) ;
381
-
382
- // Refresh jemalloc stats
383
- e. advance ( ) . unwrap ( ) ;
384
-
385
- // Get memory stats after the code block
386
- let allocated_after = stats:: allocated:: read ( ) . unwrap ( ) ;
387
-
388
- // Calculate the difference
389
- let allocated_diff = allocated_after - allocated_before;
390
-
391
- // Assert or print the difference
392
- println ! ( "Memory allocated for Vec<i32>: {} bytes" , allocated_diff) ;
393
- assert ! ( allocated_diff > 0 ) ;
394
- }
395
335
}
0 commit comments