Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - adding callsite information and clear functionality to TuneUp #37

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions TuneUp/ProfiledNodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ public string StateDescription
}
}

private string callsiteData;
/// <summary>
/// A string representing the serialized trace data contained in this callsite.
/// </summary>
public string CallSiteData
{
get { return callsiteData; }
set
{
callsiteData = value;
RaisePropertyChanged(nameof(CallSiteData));
}
}

internal NodeModel NodeModel { get; set; }

#endregion
Expand Down
2 changes: 1 addition & 1 deletion TuneUp/TuneUp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</Target>
-->
<PropertyGroup>
<DynamoVersion>2.5</DynamoVersion>
<DynamoVersion>2.11</DynamoVersion>
<PackageName>TuneUp</PackageName>
<PackageFolder>$(ProjectDir)dist\$(PackageName)\</PackageFolder>
<BinFolder>$(PackageFolder)bin\</BinFolder>
Expand Down
25 changes: 25 additions & 0 deletions TuneUp/TuneUpWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
Padding="5,2,5,2">
Force Re-execute
</Button>
<Button
Name="ClearTraceButton"
Width="Auto"
Height="Auto"
Margin="2,1,1,10"
Click="ClearTrace_Click"
Padding="5,2,5,2">
Clear Trace/ElementBinding Data
</Button>
<Label Foreground="White">Total Graph Execution Time: </Label>
<Label Foreground="White"
Name="TotalGraphExecutiontimeLabel"
Expand Down Expand Up @@ -189,6 +198,22 @@
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

<!-- callsite data -->
<DataGridTextColumn
Header="callsite data"
Binding="{Binding CallSiteData}"
Foreground="#aaaaaa"
IsReadOnly="True"
Width="Auto">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock" >
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextBlock.TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="10,0,10,0"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

</DataGrid.Columns>
</DataGrid>
</StackPanel>
Expand Down
20 changes: 20 additions & 0 deletions TuneUp/TuneUpWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System.Windows.Controls;
using Dynamo.Extensions;
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Workspaces;
using Dynamo.Models;
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.Extensions;

namespace TuneUp
Expand Down Expand Up @@ -90,5 +92,23 @@ private void RecomputeGraph_Click(object sender, RoutedEventArgs e)
{
(NodeAnalysisTable.DataContext as TuneUpWindowViewModel).ResetProfiling();
}

private void ClearTrace_Click(object sender, RoutedEventArgs e)
{
var engine = (viewLoadedParams.CurrentWorkspaceModel as HomeWorkspaceModel).EngineController;
var callsites = engine.LiveRunnerRuntimeCore.RuntimeData.GetCallsitesForNodes(
viewLoadedParams.CurrentWorkspaceModel.Nodes.Select(x => x.GUID),
engine.LiveRunnerCore.DSExecutable);

foreach (var kvp in callsites)
{
foreach (var callsite in kvp.Value)
{
callsite.TraceData.Clear();
}
}
(NodeAnalysisTable.DataContext as TuneUpWindowViewModel).GetCallSiteDataForCurrentNodesAndUpdateView();

}
}
}
15 changes: 15 additions & 0 deletions TuneUp/TuneUpWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,24 @@ private void CurrentWorkspaceModel_EvaluationCompleted(object sender, Dynamo.Mod
ProfiledNodesCollection.SortDescriptions.Add(new SortDescription(nameof(ProfiledNodeViewModel.ExecutionOrderNumber), ListSortDirection.Descending));
if (ProfiledNodesCollection.View != null)
ProfiledNodesCollection.View.Refresh();
GetCallSiteDataForCurrentNodesAndUpdateView();
});
}

internal void GetCallSiteDataForCurrentNodesAndUpdateView()
{
foreach (var item in ProfiledNodes)
{
if (item.NodeModel != null)
{
var engine = (viewLoadedParams.CurrentWorkspaceModel as HomeWorkspaceModel).EngineController;
var callsites = engine.LiveRunnerRuntimeCore.RuntimeData.GetCallsitesForNodes(new Guid[] { (item.NodeModel.GUID) }, engine.LiveRunnerCore.DSExecutable).FirstOrDefault();
item.CallSiteData = String.Join(Environment.NewLine, callsites.Value.Select(x => x.GetTraceDataToSave()));
}

}
}

/// <summary>
/// Update execution time rows. These rows are always removed and re-added after each run.
/// May consider instead, always updating them in the future.
Expand Down