Esempio n. 1
0
 public void Initialize(BenchmarkConfiguration config, BenchmarkData benchmarkData)
 {
     this.config        = config;
     this.benchmarkData = benchmarkData;
     echoServer         = new EchoServer(config, benchmarkData);
     echoClients        = new List <EchoClient>();
 }
Esempio n. 2
0
 public void ExecuteExports(BenchmarkData benchmarkData, string path)
 {
     foreach (var export in _listExport)
     {
         Console.Out.WriteLine(export.name);
         export.Export(benchmarkData, path);
     }
 }
Esempio n. 3
0
        public static void Start(string label)
        {
            var bd = new BenchmarkData()
            {
                Label = label
            };

            _startStack.Push(bd);
        }
Esempio n. 4
0
 public virtual void SaveItem()
 {
     BenchmarkData data = new BenchmarkData
     {
         Name = "John",
         Lastname = "Snow",
         Birthdate = DateTime.Now.Subtract(TimeSpan.FromDays(459))
     };
     _repository.InsertBenchmarkData(data);
 }
Esempio n. 5
0
    private IEnumerator StartBench(string runName, bool writeToCsv = true)
    {
        TimeSpent = 0;
        Data      = new Dictionary <float, List <CSVData> >();

        float timer = 0;

        // warmup to let the fps stabilize
        while ((timer += Time.deltaTime) < 4.0f)
        {
            TimeSpent += (Time.unscaledDeltaTime - TimeSpent) * 0.1f;

            yield return(new WaitForSeconds(Time.deltaTime));
        }

        var time = Time.time;

        _animator.SetTrigger("StartBench");

        // wait for the animation to start
        yield return(new WaitUntil(() => _animator.GetCurrentAnimatorStateInfo(0).IsName("Benchmark")));

        yield return(new WaitUntil(() =>
        {
            TimeSpent += (Time.unscaledDeltaTime - TimeSpent) * 0.1f;


            var ms = 1000.0f * TimeSpent;
            var fps = 1.0f / TimeSpent;
            var timeSinceStart = Mathf.Round(Time.time - time);

            List <CSVData> list;
            Data.TryGetValue(timeSinceStart, out list);

            if (list == null)
            {
                Data[timeSinceStart] = new List <CSVData>();
            }
            var benchMarkD = new BenchmarkData(ms, fps, timeSinceStart);
            var frameD = _currentFrameData;

            Data[timeSinceStart].Add(new CSVData(frameD, benchMarkD));

            _fpsText.SetText($"{fps:0.0} FPS");
            _frametimeText.SetText($"{ms:0.} ms, time elapsed: {timeSinceStart} - {runName}");

            return !_animator.GetCurrentAnimatorStateInfo(0).IsName("Benchmark");
        }));


        if (writeToCsv)
        {
            WriteToCsv(runName);
        }
    }
Esempio n. 6
0
        public void Test()
        {
            var processor = new BenchmarkProcessor();
            var request   = new BenchmarkData();
            //request.SourceCode1 = "System.Threading.Thread.Sleep(10);";
            //request.SourceCode2 = "System.Threading.Thread.Sleep(100);";
            var response = processor.Benchmark(request);

            Assert.IsTrue(response.Success);
            //Assert.IsTrue(response.Source1Ratio > 5*response.Source2Ratio);
        }
Esempio n. 7
0
        public EnetClient(int id, BenchmarkConfiguration config, BenchmarkData benchmarkData)
        {
            this.id            = id;
            this.config        = config;
            this.benchmarkData = benchmarkData;
            message            = config.Message;
            timeout            = Utilities.CalculateTimeout(this.config.ClientTickRate);

            host    = new Host();
            address = new Address();
            address.SetHost(config.Address);
            address.Port = (ushort)config.Port;
            IsDisposed   = false;
        }
        public EchoServer(BenchmarkConfiguration config, BenchmarkData benchmarkData)
        {
            this.config        = config;
            this.benchmarkData = benchmarkData;
            timeout            = Utilities.CalculateTimeout(this.config.ServerTickRate);

            host    = new Host();
            address = new Address();
            message = new byte[config.MessageByteSize];

            address.Port = (ushort)config.Port;
            address.SetHost(config.Address);
            serverThread      = new Thread(this.Start);
            serverThread.Name = "Enet Server";
        }
Esempio n. 9
0
        public EchoServer(BenchmarkConfiguration config, BenchmarkData benchmarkData)
        {
            this.config        = config;
            this.benchmarkData = benchmarkData;

            listener                  = new EventBasedNetListener();
            netManager                = new NetManager(listener);
            netManager.UpdateTime     = Utilities.CalculateTimeout(config.ServerTickRate);
            netManager.IPv6Enabled    = IPv6Mode.Disabled;
            netManager.UnsyncedEvents = true;

            message = new byte[config.MessageByteSize];

            listener.ConnectionRequestEvent += OnConnectionRequest;
            listener.NetworkReceiveEvent    += OnNetworkReceive;
            listener.NetworkErrorEvent      += OnNetworkError;
        }
Esempio n. 10
0
    public static void RunBenchmark(BenchmarkData benchmarkData)
    {
        // Prepare benchmark
        Console.Clear();
        currentBenchmarkResults = new BenchmarkResults();
        currentBenchmarkResults.SetData(benchmarkData);

        // Run 2 benchmarks. One for each type
        SeparationLine();
        RunTests(benchmarkData.changesAmount, benchmarkData.testsAmount, benchmarkData.benchmark1);
        SeparationLine();
        RunTests(benchmarkData.changesAmount, benchmarkData.testsAmount, benchmarkData.benchmark2);
        SeparationLine();

        // Finish benchmark
        DisplayResults();
    }
Esempio n. 11
0
    public static void AddDataFromInput(int input, bool printAfter = true)
    {
        // Adds the data by the user's input
        // Prints the next section
        // Or starts the benchmark if it is the last section

        if (IsNumberValid(input))
        {
            int inputForArray = input - 1;
            switch (currentSection)
            {
            case ChoosingState.ChoosingComparisons:
                currentBenchmarkData = new BenchmarkData(BenchmarksManager.comparisons[inputForArray]);
                currentSection       = ChoosingState.ChoosingDuration;
                if (printAfter)
                {
                    PrintSection();
                }
                break;

            case ChoosingState.ChoosingDuration:
                currentBenchmarkPresetGroup = BenchmarksManager.benchmarkPresetGroups[inputForArray];
                currentSection = ChoosingState.ChoosingPreset;
                if (printAfter)
                {
                    PrintSection();
                }
                break;

            case ChoosingState.ChoosingPreset:
                currentSection = ChoosingState.Complete;
                currentBenchmarkData.InputPreset(currentBenchmarkPresetGroup.presets[inputForArray], currentBenchmarkPresetGroup.Name, input);
                BenchmarksManager.RunBenchmark(currentBenchmarkData);
                break;

            default:
                break;
            }
        }

        else
        {
            ActiveError("Number is invalid. Number: <" + input + ">");
        }
    }
        public EchoClient(int id, BenchmarkConfiguration config, BenchmarkData benchmarkData)
        {
            this.id            = id;
            this.config        = config;
            this.benchmarkData = benchmarkData;
            message            = config.Message;

            listener                     = new EventBasedNetListener();
            netManager                   = new NetManager(listener);
            netManager.IPv6Enabled       = IPv6Mode.Disabled;
            netManager.UpdateTime        = Utilities.CalculateTimeout(config.ClientTickRate);
            netManager.UnsyncedEvents    = true;
            netManager.DisconnectTimeout = 10000;

            IsConnected = false;
            IsDisposed  = false;

            listener.PeerConnectedEvent    += OnPeerConnected;
            listener.PeerDisconnectedEvent += OnPeerDisconnected;
            listener.NetworkReceiveEvent   += OnNetworkReceive;
            listener.NetworkErrorEvent     += OnNetworkError;
        }
 public EchoServer(BenchmarkConfiguration config, BenchmarkData benchmarkData) : base(IPAddress.Any, config.Port)
 {
     this.benchmarkData = benchmarkData;
 }
Esempio n. 14
0
 public static void Start(string label)
 {
     var bd = new BenchmarkData() { Label = label };
     _startStack.Push(bd);
 }
Esempio n. 15
0
    /// <summary>
    /// Main test loop. (Coroutine)
    /// </summary>
    /// <returns>
    /// The <see cref="IEnumerator"/>.
    /// </returns>
    public IEnumerator MainNHTestLoop()
    {
        CurrentMapIndex = 0;
        foreach (var txa in allMaps)
        {
            /* Update the map and recompute the map. */
            BDPMap.Instance.MapFile = txa;
            BDPMap.Instance.ComputeMap();

            var bd = new BenchmarkData(this) { TMin = Windows };

            while (!BDPMap.Instance.MapIsLoaded)
            {
                yield return new WaitForSeconds(0.5f);
            }

            agent.CleanBelief();

        #if PATHTESTER_DEBUG_LOG
            Debug.Log(string.Format("[MAINLOOP] Starting Iteration on map {0}", txa.name));
        #endif
            CurrentMapIteration = 0;
            agent.CurrentPosition = this.RandomFreePosition();
            RandomStrategy.Init();
            while (CurrentMapIteration < NumberOfRuns)
            {
        #if PATHTESTER_DEBUG_LOG
                Debug.Log("--------------------------------------------------");
                Debug.Log(string.Format("[MAINLOOP] Computing Path {0} of {1}", CurrentMapIteration + 1, NumberOfRuns));
        #endif

                // Debug.Log("Iteration " + counter);
                if (CurrentMapIteration % ScrambleRate == 0)
                {
        #if PATHTESTER_DEBUG_LOG
                    Debug.Log("[MAINLOOP] Randomizing Portals");
        #endif
                    StepCounter.Increase();
                    RandomStrategy.RandomizeWorldPortals();
                }

                var targetPos = this.DraftRandomTargetPos();

                /* BENCHMARK */
                InitializeSRD(agent.CurrentPosition, targetPos);

                /* ********* */
                UpdateAllPortalInArea(agent.CurrentPosition);

                var startTime = 0;
                var valid = true;

                while (agent.CurrentPosition != targetPos)
                {
                    startTime++;
                    this.executionError = false;
                    if (startTime > 30)
                    {
                        srd.PathFound = false;
                        Debug.Log("[MAINLOOP] Time out! Go to next pick.");
                        valid = false;
                        break;
                    }

        #if PATHTESTER_DEBUG_LOG
                    Debug.Log(string.Format("[MAINLOOP] Execution Step from {0} to {1}", agent.CurrentPosition, targetPos));
        #endif

                    if (ThePathfinder.AgentBelief.Hierarchical)
                    {
                        ThePathfinder.AgentBelief.CurrentTarget = targetPos;
                    }

                    if (!Caching) {
                        agent.ReviewBeliefOlderThan(Windows);
                    }

                    var path = ThePathfinder.PathFind(agent.CurrentPosition, targetPos);

                    /* BENCHMARK */
                    UpdateSRD();

                    if (path == null)
                    {

                        Debug.Log("[MAINLOOP] No path found! Try to perform belief revision.");
                        if (ThePathfinder.AgentBelief.Hierarchical)
                        {
                            Debug.Log("[MAINLOOP] Starting Belief Revision Loop");
                            path = BeliefRevisionLoop(agent.CurrentPosition, targetPos);
                        }

                        if (path == null)
                        {
                            srd.PathFound = false;
        #if PATHTESTER_DEBUG_LOG
                            Debug.Log("[MAINLOOP] No path found! Go to next pick.");
        #endif
                            break;
                        }
                    }

                    srd.PathFound = true;

                    /* ********* */
                    var pathList = Path2MapSquareList(path);

                    //Debug.Log("[MAINLOOP] Path Found. Start Execution.");
                    if (ThePathfinder.AgentBelief.Hierarchical)
                    {
                        yield return StartCoroutine(ExecuteHierarchicalPath(pathList));
                    }
                    else
                    {
                        yield return StartCoroutine(ExecutePath(pathList));
                    }
                }

                if (true)
                {
                    CurrentMapIteration++;
                    bd.RunsData.Add(srd);
                }

                yield return new WaitForSeconds(0.1f);
            }

            bd.PrintToFile();
            CurrentMapIndex++;
        }

        #if PATHTESTER_DEBUG_LOG
        myLogger.Log("[MAINLOOP] TEST COMPLETED");
        #endif
    }
Esempio n. 16
0
 public CSVData(FrameData frameData, BenchmarkData benchmarkData)
 {
     FrameData     = frameData;
     BenchmarkData = benchmarkData;
 }
Esempio n. 17
0
 public BenchmarkModel()
 {
     BenchmarkData = new BenchmarkData();
     BenchmarkData.SetSourceCode(0, 0, "var x = \"abc\" + \"def\";");
     BenchmarkData.SetSourceCode(0, 1, "var x = string.Format(\"{0}{1}\", \"abc\", \"def\");");
 }
 public EchoClient(int id, BenchmarkConfiguration config, BenchmarkData benchmarkData) : base(id, config, benchmarkData)
 {
 }
 public EchoClient(BenchmarkConfiguration config, BenchmarkData benchmarkData) : base(config.Address, config.Port)
 {
     message            = config.Message;
     initialMessages    = config.ParallelMessages;
     this.benchmarkData = benchmarkData;
 }
 public EchoClientThreaded(int id, BenchmarkConfiguration config, BenchmarkData benchmarkData) : base(id, config, benchmarkData)
 {
     connectAndListenThread              = new Thread(ConnectAndListen);
     connectAndListenThread.Name         = $"ENet Client {id}";
     connectAndListenThread.IsBackground = true;
 }