예제 #1
0
        private static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Please provide an ETL file name.");
                return 1;
            }

            TraceReader reader = new TraceReader(args[0]);
            EventLatencyCollector latencyCollector = new EventLatencyCollector();
            List<double> latencies = new List<double>();
            latencyCollector.EventCompleted += (o, e) => latencies.Add(e.Latency.TotalSeconds);

            EventWindowCollector windowCollector = new EventWindowCollector();
            DateTime startTime = DateTime.MinValue;
            windowCollector.WindowClosed += (o, e) => OnWindowClosed(ref startTime, e.Window);

            Console.WriteLine("Window,Pending,Completed");
            reader.ReadAsync(new CompositeEventCollector(windowCollector, latencyCollector)).Wait();
            
            windowCollector.CloseWindow();
            Console.WriteLine();

            CalculatePercentiles(latencies);

            return 0;
        }
예제 #2
0
        List <ICommand> IStrategy.MakeTrace(TModel src, TModel dst)
        {
            var traceFile = $"{tracesDir}/{dst.Name}.nbt";

            return(File.Exists(traceFile)
                ? TraceReader.Read(traceFile)
                : new List <ICommand>());
        }
    /// <summary>
    /// ONGUI function for drawing GUI functionally
    /// </summary>
    void OnGUI()
    {
        GUILayout.Label("Global Simulation Settings", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        showCrowdGenerator = EditorGUILayout.Foldout(showCrowdGenerator, "Random Crowd Generator");
        if (showCrowdGenerator)
        {
            floor               = (Transform)EditorGUILayout.ObjectField("Floor", floor, typeof(Transform));
            target              = (Transform)EditorGUILayout.ObjectField("Goal", target, typeof(Transform));
            edgeBuffer          = EditorGUILayout.FloatField("Edgebuffer", edgeBuffer);
            numNormativeAgents  = EditorGUILayout.IntSlider("Normative Agents", numNormativeAgents, 0, 1000);
            numDistractedAgents = EditorGUILayout.IntSlider("Distracted Agents", numDistractedAgents, 0, 1000);

            if (GUILayout.Button("Create Agents"))
            {
                GenerateRandomAgents();
            }
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("Delete All Agents In Scene"))
        {
            GameObject[] agents = GameObject.FindGameObjectsWithTag("Agent");
            for (int i = 0; i < agents.Length; i++)
            {
                DestroyImmediate(agents [i]);
            }
        }

        EditorGUILayout.Space();
        showTraceOptions = EditorGUILayout.Foldout(showTraceOptions, "Trace Reader Options");
        if (showTraceOptions)
        {
            EditorGUILayout.LabelField("To playback trace file, check the box.");
            EditorGUILayout.LabelField("To instantiate agents from the trace file, press the button (initialize only).");
            file = (TextAsset)EditorGUILayout.ObjectField("Trace File", file, typeof(TextAsset));
            boolReadTraceFile = EditorGUILayout.Toggle("Playback from trace", boolReadTraceFile);
            TraceReader traceReaderScript = Camera.main.GetComponent <TraceReader> ();
            if (boolReadTraceFile)
            {
                traceReaderScript.file    = file;
                traceReaderScript.enabled = true;
            }
            else
            {
                traceReaderScript.enabled = false;
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("Create Agents From Trace"))
            {
                GenerateAgentsFromTrace();
            }
        }
    }
예제 #4
0
        private void LoadTrace(string traceFile)
        {
            var trace  = TraceReader.Read(File.ReadAllBytes(traceFile));
            var state  = new TState(new TModel("FA055_tgt.mdl"), true);
            var reader = new TCommandsReader(trace);

            while (!reader.AtEnd())
            {
                state.Step(reader);
            }
        }
예제 #5
0
        public void TestRoundtrip()
        {
            var inBytes  = File.ReadAllBytes("FR112.nbt");
            var commands = TraceReader.Read(inBytes);
            var outBytes = TraceSerializer.Serialize(commands);

            Assert.AreEqual(inBytes.Length, outBytes.Length);
            for (var i = 0; i < inBytes.Length; i++)
            {
                Assert.AreEqual(inBytes[i], outBytes[i], string.Format("byte #{0}", i));
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("Usage: TRACE_FILE");
                Environment.Exit(1);
            }
            var bytes    = File.ReadAllBytes(args[0]);
            var commands = TraceReader.Read(bytes);

            foreach (var cmd in commands)
            {
                Console.WriteLine(cmd);
            }
        }
예제 #7
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        // load trace data
        for (int i = 0; i < TRACE_MAX; i++)
        {
            tracePositions.Insert(i, new List <float[]>());
            List <float[]> position = tracePositions[i];
            if (loadTraceFromCSV(traceFileName + (i + 1).ToString(), ref position))
            {
                /////////
                // custom trajactory
                //UnityEngine.Random.InitState(5566);
                //float offset_x = UnityEngine.Random.Range(-0.2f, 0.2f);
                //float offset_y = UnityEngine.Random.Range(0.0f, 0.4f);

                //position.Clear();
                //for (int j = 0; j < 360; j++)
                //{
                //    float[] f = new float[4];
                //    float count = 0;
                //    float cos = Mathf.Cos(j * 2 * Mathf.Deg2Rad);
                //    float sin = Mathf.Sin(j * 2 * Mathf.Deg2Rad);
                //    f[0] = count;
                //    f[1] = cos * 0.5f * 0.5f + 0.5f + offset_x;
                //    f[2] = sin * 0.5f * 0.25f + 0.5f + offset_y;
                //    f[3] = 0;
                //    //Debug.Log("Frame " + f[0] + " : X=" + f[1] + " Y=" + f[2]);
                //    position.Add(f);
                //    count++;
                //}
                //FRAME_MAX = 360;
                ////////
                SpawnBird(i);
            }
            else
            {
                break;
            }
        }
        InitBirdInfos();
        ProcessBirdInfos();
    }