public static void execute(List <Action> callables,
                                   AtomicInteger noEstimateCounter,
                                   IRunningAverageAndStdDev timing)
        {
            List <Action> wrappedCallables = wrapWithStatsCallables(callables, noEstimateCounter, timing);
            int           numProcessors    = Environment.ProcessorCount;
            var           tasks            = new Task[wrappedCallables.Count];

            log.Info("Starting timing of {} tasks in {} threads", wrappedCallables.Count, numProcessors);
            try {
                for (int i = 0; i < tasks.Length; i++)
                {
                    tasks[i] = Task.Factory.StartNew(wrappedCallables[i]);
                }
                Task.WaitAll(tasks, 10000);   // 10 sec

                /*List<Future<Void>> futures = executor.invokeAll(wrappedCallables);
                 * // Go look for exceptions here, really
                 * for (Future<Void> future : futures) {
                 * future.get();
                 * }*/
            } catch (Exception e) {
                throw new TasteException(e.Message, e);
            }

            /*executor.shutdown();
             * try {
             * executor.awaitTermination(10, TimeUnit.SECONDS);
             * } catch (InterruptedException e) {
             * throw new TasteException(e.getCause());
             * }*/
        }
  public StatsCallable(Action deleg,
                bool logStats,
                IRunningAverageAndStdDev timing,
				AtomicInteger noEstimateCounter) {
    this._Delegate = deleg;
    this.logStats = logStats;
    this.timing = timing;
    this.noEstimateCounter = noEstimateCounter;
  }
示例#3
0
 public StatsCallable(Action deleg,
                      bool logStats,
                      IRunningAverageAndStdDev timing,
                      AtomicInteger noEstimateCounter)
 {
     this._Delegate         = deleg;
     this.logStats          = logStats;
     this.timing            = timing;
     this.noEstimateCounter = noEstimateCounter;
 }
        private static List <Action> wrapWithStatsCallables(List <Action> callables,
                                                            AtomicInteger noEstimateCounter,
                                                            IRunningAverageAndStdDev timing)
        {
            List <Action> wrapped = new List <Action>();

            for (int count = 0; count < callables.Count; count++)
            {
                bool logStats = count % 1000 == 0; // log every 1000 or so iterations
                wrapped.Add(new StatsCallable(callables[count], logStats, timing, noEstimateCounter).call);
            }
            return(wrapped);
        }
  private static List<Action> wrapWithStatsCallables(List<Action> callables,
                                                                   AtomicInteger noEstimateCounter,
                                                                   IRunningAverageAndStdDev timing) {
    List<Action> wrapped = new List<Action>();
    for (int count=0; count<callables.Count; count++) {
      bool logStats = count % 1000 == 0; // log every 1000 or so iterations
	  wrapped.Add(new StatsCallable(callables[count], logStats, timing, noEstimateCounter).call);
    }
    return wrapped;
  }
  public static void execute(List<Action> callables,
                                AtomicInteger noEstimateCounter,
                                IRunningAverageAndStdDev timing) {

    List<Action> wrappedCallables = wrapWithStatsCallables(callables, noEstimateCounter, timing);
    int numProcessors = Environment.ProcessorCount;
    var tasks = new Task[wrappedCallables.Count];
    log.Info("Starting timing of {} tasks in {} threads", wrappedCallables.Count, numProcessors);
    try {
		for (int i=0; i<tasks.Length; i++)
			tasks[i] = Task.Factory.StartNew( wrappedCallables[i] );
		Task.WaitAll( tasks, 10000 ); // 10 sec
      /*List<Future<Void>> futures = executor.invokeAll(wrappedCallables);
      // Go look for exceptions here, really
      for (Future<Void> future : futures) {
        future.get();
      }*/

    } catch (Exception e) {
      throw new TasteException(e.Message, e);
    }
    
    /*executor.shutdown();
    try {
      executor.awaitTermination(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      throw new TasteException(e.getCause());
    }*/
  }
 public InvertedRunningAverageAndStdDev(IRunningAverageAndStdDev deleg) {
   this._Delegate = deleg;
 }
示例#8
0
 public InvertedRunningAverageAndStdDev(IRunningAverageAndStdDev deleg)
 {
     this._Delegate = deleg;
 }