@@ -8,8 +8,6 @@ use unilang::simd_json_parser::{ SIMDJsonParser, FastJsonValue };
88use serde_json:: Value as SerdeValue ;
99use unilang:: { Value , Kind , types:: parse_value } ;
1010
11- #[ cfg( feature = "benchmarks" ) ]
12- use benchkit:: prelude:: * ;
1311
1412/// Test basic SIMD JSON parsing correctness
1513#[ test]
@@ -342,87 +340,6 @@ fn test_simd_json_formatting_compatibility()
342340 }
343341}
344342
345- /// Benchmark comparison test to validate performance improvements using benchkit
346- #[ cfg( feature = "benchmarks" ) ]
347- #[ test]
348- fn test_simd_performance_validation ( )
349- {
350- println ! ( "🚀 SIMD Performance Validation using Benchkit" ) ;
351- println ! ( "=============================================" ) ;
352-
353- // Generate medium-sized JSON for performance testing
354- let mut test_json = r#"{"performance_test":{"data":["# . to_string ( ) ;
355- for i in 0 ..500
356- {
357- if i > 0 { test_json. push ( ',' ) ; }
358- use core:: fmt:: Write ;
359- write ! ( & mut test_json,
360- r#"{{"id":{i},"name":"item{i}","value":{},"tags":["tag1","tag2"],"meta":{{"created":"2024-01-01","active":{}}}}}"# ,
361- f64 :: from( i) * 1.5 , i % 2 == 0
362- ) . unwrap ( ) ;
363- }
364- test_json. push_str ( "]}}" ) ;
365-
366- println ! ( "📊 JSON payload size: {} bytes" , test_json. len( ) ) ;
367- println ! ( "🧪 Running comparative analysis..." ) ;
368-
369- let simd_json_data = test_json. clone ( ) ;
370- let serde_json_data = test_json. clone ( ) ;
371-
372- let comparison = ComparativeAnalysis :: new ( "simd_performance_validation" )
373- . algorithm ( "simd_json" , move ||
374- {
375- let _ = SIMDJsonParser :: parse_to_serde_value ( & simd_json_data ) . unwrap ( ) ;
376- } )
377- . algorithm ( "serde_json" , move ||
378- {
379- let _ = serde_json:: from_str :: < SerdeValue > ( & serde_json_data ) . unwrap ( ) ;
380- } ) ;
381-
382- let report = comparison. run ( ) ;
383-
384- // Display comprehensive benchmark results
385- println ! ( "📈 Performance Results:" ) ;
386- for ( name, result ) in report. sorted_by_performance ( )
387- {
388- println ! ( " • {}: {:.0} ops/sec ({:.3}ms)" , name, result. operations_per_second( ) , result. mean_time( ) . as_secs_f64( ) * 1000.0 ) ;
389- }
390-
391- // Calculate and validate performance expectations
392- if let Some ( ( fastest_name, fastest_result ) ) = report. fastest ( )
393- {
394- if let Some ( ( slowest_name, slowest_result ) ) = report. slowest ( )
395- {
396- let speedup = slowest_result. mean_time ( ) . as_nanos ( ) as f64 / fastest_result. mean_time ( ) . as_nanos ( ) as f64 ;
397- println ! ( "⚡ Speedup: {fastest_name} is {speedup:.2}x faster than {slowest_name}" ) ;
398-
399- // Validate performance characteristics with realistic expectations
400- if fastest_name == "simd_json"
401- {
402- println ! ( "✅ SIMD JSON outperforms standard JSON parsing" ) ;
403- }
404- else
405- {
406- println ! ( "⚠️ Standard serde_json outperformed SIMD (may indicate debug build, small payload, or sub-optimal conditions)" ) ;
407- }
408-
409- // Performance validation - SIMD should be reasonable but may not always win
410- // In debug builds or with certain payload characteristics, serde_json might be faster
411- let performance_difference = ( slowest_result. mean_time ( ) . as_nanos ( ) as f64 / fastest_result. mean_time ( ) . as_nanos ( ) as f64 ) - 1.0 ;
412-
413- assert ! ( performance_difference <= 5.0 , "Performance difference is too extreme ({:.1}x) - investigate SIMD implementation" , performance_difference + 1.0 ) ;
414-
415- println ! ( "✅ Performance validation passed - algorithms perform within reasonable bounds" ) ;
416- }
417- }
418-
419- // Display SIMD capability information
420- println ! ( "🔧 SIMD Capability Detection:" ) ;
421- println ! ( " • SIMD support: {}" , SIMDJsonParser :: is_simd_supported( ) ) ;
422- println ! ( " • SIMD info: {}" , SIMDJsonParser :: simd_info( ) ) ;
423-
424- println ! ( "✨ Benchkit provides statistical rigor and clear PASS/FAIL validation for SIMD performance!" ) ;
425- }
426343
427344/// Fallback test for when benchmarks feature is not enabled
428345#[ cfg( not( feature = "benchmarks" ) ) ]
0 commit comments