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

[DYN-2369] Export TuneUp node timings #49

Merged
Merged
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
12 changes: 11 additions & 1 deletion TuneUp/TuneUpWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@
IsEnabled="{Binding Path=IsRecomputeEnabled}"
Click="RecomputeGraph_Click"
Padding="5,2,5,2">
Force Re-execute
Run All
</Button>
<Button
Name="ExportTimes"
Width="Auto"
Height="Auto"
Margin="2,1,1,10"
Padding="5,2,5,2"
IsEnabled="{Binding Path=IsRecomputeEnabled}"
Click="ExportTimes_Click">
Export
</Button>
<Label Foreground="White">Total Graph Execution Time: </Label>
<Label Foreground="White"
Expand Down
5 changes: 5 additions & 0 deletions TuneUp/TuneUpWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,10 @@ private void RecomputeGraph_Click(object sender, RoutedEventArgs e)
{
(NodeAnalysisTable.DataContext as TuneUpWindowViewModel).ResetProfiling();
}

private void ExportTimes_Click(object sender, RoutedEventArgs e)
{
(NodeAnalysisTable.DataContext as TuneUpWindowViewModel).ExportToCsv();
}
}
}
29 changes: 29 additions & 0 deletions TuneUp/TuneUpWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Data;
Expand All @@ -12,6 +13,7 @@
using Dynamo.Graph.Workspaces;
using Dynamo.ViewModels;
using Dynamo.Wpf.Extensions;
using Microsoft.Win32;

namespace TuneUp
{
Expand Down Expand Up @@ -448,5 +450,32 @@ public void Dispose()
}

#endregion

#region Export Node times

/// <summary>
/// Exports the ProfiledNodesCollection to a CSV file.
/// </summary>
public void ExportToCsv()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
//saveFileDialog.RestoreDirectory = false;
saveFileDialog.Filter = "CSV file (*.csv)|*.csv|All files (*.*)|*.*";

if (saveFileDialog.ShowDialog() == true)
{
using (var writer = new StreamWriter(saveFileDialog.FileName))
{
writer.WriteLine("Execution Order,Name,Execution Time (ms)");

foreach (ProfiledNodeViewModel node in ProfiledNodesCollection.View.Cast<ProfiledNodeViewModel>())
{
writer.WriteLine($"{node.ExecutionOrderNumber},{node.Name},{node.ExecutionMilliseconds}");
}
}
}
}

#endregion
}
}