public void benchmark ( File fllFile , File fldFile , int runs , Writer writer ) throws Exception { Engine engine = new FllImporter ( ) . fromFile ( fllFile ) ; Reader reader = new InputStreamReader ( new FileInputStream ( fldFile ) , FuzzyLite . UTF_8 ) ; try { Benchmark benchmark = new Benchmark ( engine . getName ( ) , engine ) ; benchmark . prepare ( reader ) ; if ( writer != null ) { FuzzyLite . logger ( ) . log ( Level . INFO , "\tEvaluating on {0} values read from {1}" , new Object [ ] { benchmark . getExpected ( ) . size ( ) , fldFile . getAbsolutePath ( ) } ) ; } for ( int i = 0 ; i < runs ; ++ i ) { benchmark . runOnce ( ) ; } String results = benchmark . format ( benchmark . results ( ) , Benchmark . TableShape . Horizontal , Benchmark . TableContents . Body ) + "\n" ; if ( writer != null ) { double [ ] times = new double [ benchmark . getTimes ( ) . size ( ) ] ; for ( int i = 0 ; i < benchmark . getTimes ( ) . size ( ) ; ++ i ) { times [ i ] = benchmark . getTimes ( ) . get ( i ) ; } FuzzyLite . logger ( ) . log ( Level . INFO , "\tMean(t)={0}" , Op . str ( Op . mean ( times ) ) ) ; writer . write ( results ) ; writer . flush ( ) ; } else { System . out . println ( results ) ; } } catch ( Exception ex ) { throw ex ; } finally { reader . close ( ) ; } }
Benchmarks the engine described in the FLL file against the dataset contained in the FLD file .