@@ -31,55 +31,53 @@ static void Main(string[] args)
3131 {
3232 var errors = new List < string > ( ) ;
3333 var success = new List < string > ( ) ;
34- var disabled = new List < string > ( ) ;
3534 var examples = Assembly . GetEntryAssembly ( ) . GetTypes ( )
3635 . Where ( x => x . GetInterfaces ( ) . Contains ( typeof ( IExample ) ) )
3736 . Select ( x => ( IExample ) Activator . CreateInstance ( x ) )
37+ . Where ( x => x . Enabled )
38+ . OrderBy ( x => x . Name )
3839 . ToArray ( ) ;
3940
40- Console . WriteLine ( $ "TensorFlow v{ tf . VERSION } ", Color . Yellow ) ;
41+ Console . WriteLine ( Environment . OSVersion . ToString ( ) , Color . Yellow ) ;
42+ Console . WriteLine ( $ "TensorFlow Binary v{ tf . VERSION } ", Color . Yellow ) ;
4143 Console . WriteLine ( $ "TensorFlow.NET v{ Assembly . GetAssembly ( typeof ( TF_DataType ) ) . GetName ( ) . Version } ", Color . Yellow ) ;
4244
45+ for ( var i = 0 ; i < examples . Length ; i ++ )
46+ Console . WriteLine ( $ "[{ i } ]: { examples [ i ] . Name } ") ;
47+ Console . Write ( $ "Choose one example to run, hit [Enter] to run all: ", Color . Yellow ) ;
48+ var key = Console . ReadLine ( ) ;
49+
4350 var sw = new Stopwatch ( ) ;
44- foreach ( IExample example in examples )
51+ for ( var i = 0 ; i < examples . Length ; i ++ )
4552 {
46- if ( args . Length > 0 && ! args . Contains ( example . Name ) )
47- continue ;
53+ if ( i . ToString ( ) != key && key != "" ) continue ;
4854
55+ var example = examples [ i ] ;
4956 Console . WriteLine ( $ "{ DateTime . UtcNow } Starting { example . Name } ", Color . White ) ;
5057
5158 try
5259 {
53- if ( example . Enabled || args . Length > 0 ) // if a specific example was specified run it, regardless of enabled value
54- {
55- sw . Restart ( ) ;
56- bool isSuccess = example . Run ( ) ;
57- sw . Stop ( ) ;
60+ sw . Restart ( ) ;
61+ bool isSuccess = example . Run ( ) ;
62+ sw . Stop ( ) ;
5863
59- if ( isSuccess )
60- success . Add ( $ "Example: { example . Name } in { sw . Elapsed . TotalSeconds } s") ;
61- else
62- errors . Add ( $ "Example: { example . Name } in { sw . Elapsed . TotalSeconds } s") ;
63- }
64+ if ( isSuccess )
65+ success . Add ( $ "Example: { example . Name } in { sw . Elapsed . TotalSeconds } s") ;
6466 else
65- {
66- disabled . Add ( $ "Example: { example . Name } in { sw . ElapsedMilliseconds } ms") ;
67- }
67+ errors . Add ( $ "Example: { example . Name } in { sw . Elapsed . TotalSeconds } s") ;
6868 }
6969 catch ( Exception ex )
7070 {
7171 errors . Add ( $ "Example: { example . Name } ") ;
7272 Console . WriteLine ( ex ) ;
7373 }
74-
74+
7575 Console . WriteLine ( $ "{ DateTime . UtcNow } Completed { example . Name } ", Color . White ) ;
7676 }
7777
7878 success . ForEach ( x => Console . WriteLine ( $ "{ x } is OK!", Color . Green ) ) ;
79- disabled . ForEach ( x => Console . WriteLine ( $ "{ x } is Disabled!", Color . Tan ) ) ;
8079 errors . ForEach ( x => Console . WriteLine ( $ "{ x } is Failed!", Color . Red ) ) ;
8180
82- Console . Write ( "Please [Enter] to quit." ) ;
8381 Console . ReadLine ( ) ;
8482 }
8583 }
0 commit comments