Exemple #1
0
    protected override void OnUpdate()
    {
        foreach (GraphStream graphStream in m_GraphStreams)
        {
            graphStream.CompleteInputDependencies();
            DebuggerTracer.GraphTrace graphTrace = DebuggerTracer.GetGraphData(graphStream.GraphId, createIfAbsent: true);
            var reader = graphStream.AsReader();
            var frame  = Time.frameCount;

            DebuggerTracer.FrameData frameData = null;
            for (int i = 0; i < reader.ForEachCount; i++)
            {
                reader.BeginForEachIndex(i);
                DebuggerTracer.EntityFrameTrace entityData = null;
                while (reader.RemainingItemCount > 0)
                {
                    if (frameData == null)
                    {
                        frameData = graphTrace.GetFrameData(frame, createIfAbsent: true);
                    }

                    var   callFrame = reader.Read <DataType>();
                    ulong nodeId1, nodeId2;
                    switch (callFrame)
                    {
                    case DataType.Entity:
                        var e = ReadEntity(ref reader);
                        entityData = frameData.GetEntityFrameTrace(e.Index, createIfAbsent: true);
                        break;

                    case DataType.Step:
                        Assert.IsTrue(entityData != null);
                        ReadStepRecord(ref reader, out nodeId1, out nodeId2, out var stepOffset, out var progress);
                        entityData.SetLastCallFrame(nodeId1, nodeId2, stepOffset, progress);
                        break;

                    case DataType.Data:
                    {
                        Assert.IsTrue(entityData != null);
                        ReadValueRecord(ref reader, out nodeId1, out nodeId2, out var value);
                        entityData.RecordValue(value, nodeId1, nodeId2);
                        break;
                    }
                    }
                }

                reader.EndForEachIndex();
            }

            graphStream.Dispose();
        }
        m_GraphStreams.Clear();
    }
Exemple #2
0
    public static DebuggerTracer.EntityFrameTrace GetRecorder(int graphId, int targetIndex)
    {
        Assert.IsTrue(InternalEditorUtility.CurrentThreadIsMainThread());
        // TODO cache graphdata/frametrace
        var frame = Time.frameCount;

        DebuggerTracer.GraphTrace graphTrace = DebuggerTracer.GetGraphData(graphId, true);
        var frameData = graphTrace.GetFrameData(frame, createIfAbsent: true);

        var entityData = frameData.GetEntityFrameTrace(targetIndex, createIfAbsent: true);

        return(entityData);
    }
Exemple #3
0
        public void TestCircularBufferHasRightValues()
        {
            DebuggerTracer.GraphTrace recorder = new DebuggerTracer.GraphTrace(10);
            const int entityId = 0;

            for (int i = 0; i < 20; i++)
            {
                DebuggerTracer.FrameData        frameData  = recorder.GetFrameData(i, true);
                DebuggerTracer.EntityFrameTrace entityData = frameData.GetEntityFrameTrace(entityId, true);
                entityData.RecordValue(i, 0, 0);
            }
            for (int i = 0; i < 20; i++)
            {
                if (i < 10)
                {
                    Assert.That(recorder.GetFrameData(i, false), Is.Null);
                }
                else
                {
                    Assert.That(recorder.GetFrameData(i, false).GetEntityFrameTrace(entityId, false).values[0].Single().readableValue, Is.EqualTo(i.ToString()));
                }
            }
        }