Пример #1
0
 public void addSearchPath(string path)
 {
     //File f = new File(path);
     //if (f.exists() && f.isDirectory())
     if (File.Exists(path) || Directory.Exists(path))
     {
         try
         {
             path = Path.GetFullPath(path);//f.getCanonicalPath();
             foreach (string prefix in searchPath)
             {
                 if (prefix == path)
                 {
                     return;
                 }
             }
             UI.printInfo(UI.Module.SYS, "Adding {0} search path: \"{1}\"", type, path);
             searchPath.AddLast(path);
         }
         catch (Exception e)
         {
             UI.printError(UI.Module.SYS, "Invalid {0} search path specification: \"{1}\" - {2}", type, path, e);
         }
     }
     else
     {
         UI.printError(UI.Module.SYS, "Invalid {0} search path specification: \"{1}\" - invalid directory", type, path);
     }
 }
Пример #2
0
        public void execute(BenchmarkTest test)
        {
            // clear previous results
            for (int i = 0; i < timers.Length; i++)
            {
                timers[i] = null;
            }
            // loop for the specified number of iterations or until the time limit
            long startTime = NanoTime.Now;

            for (int i = 0; i < timers.Length && ((NanoTime.Now - startTime) / 1000000000) < timeLimit; i++)
            {
                UI.printInfo(UI.Module.BENCH, "Running iteration {0}", (i + 1));
                timers[i] = new Timer();
                test.kernelBegin();
                timers[i].start();
                test.kernelMain();
                timers[i].end();
                test.kernelEnd();
            }
            // report stats
            double avg = 0;
            double min = double.PositiveInfinity;
            double max = double.NegativeInfinity;
            int    n   = 0;

            foreach (Timer t in timers)
            {
                if (t == null)
                {
                    break;
                }
                double s = t.seconds();
                min  = Math.Min(min, s);
                max  = Math.Max(max, s);
                avg += s;
                n++;
            }
            if (n == 0)
            {
                return;
            }
            avg /= n;
            double stdDev = 0;

            foreach (Timer t in timers)
            {
                if (t == null)
                {
                    break;
                }
                double s = t.seconds();
                stdDev += (s - avg) * (s - avg);
            }
            stdDev = Math.Sqrt(stdDev / n);
            UI.printInfo(UI.Module.BENCH, "Benchmark results:");
            UI.printInfo(UI.Module.BENCH, "  * Iterations: {0}", n);
            UI.printInfo(UI.Module.BENCH, "  * Average:    {0}", Timer.tostring(avg));
            UI.printInfo(UI.Module.BENCH, "  * Fastest:    {0}", Timer.tostring(min));
            UI.printInfo(UI.Module.BENCH, "  * Longest:    {0}", Timer.tostring(max));
            UI.printInfo(UI.Module.BENCH, "  * Deviation:  {0}", Timer.tostring(stdDev));
            for (int i = 0; i < timers.Length && timers[i] != null; i++)
            {
                UI.printDetailed(UI.Module.BENCH, "  * Iteration {0}: {1}", i + 1, timers[i]);
            }
        }