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

Graph Tessellation Benchmarks #9651

Merged
merged 11 commits into from
Apr 15, 2019
1 change: 1 addition & 0 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ limitations under the License.
<Compile Include="Library\ILibraryLoader.cs" />
<Compile Include="Graph\Workspaces\ICustomNodeWorkspaceModel.cs" />
<Compile Include="Visualization\DefaultGraphicPrimitives.cs" />
<Compile Include="Visualization\GeometryHolder.cs" />
<Compile Include="Visualization\IRenderPackageSource.cs" />
<Compile Include="Graph\Workspaces\IWorkspaceModel.cs" />
<Compile Include="Logging\LogMessage.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Models/DynamoModelEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public virtual void OnEvaluationCompleted(object sender, EvaluationCompletedEven
{
Action showFailureMessage = () => DisplayEngineFailureMessage(e.Error);
OnRequestDispatcherBeginInvoke(showFailureMessage);
}
}

if (EvaluationCompleted != null)
EvaluationCompleted(sender, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Autodesk.DesignScript.Interfaces;
using Dynamo.Interfaces;

namespace Dynamo.Visualization
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
using Autodesk.DesignScript.Interfaces;
using Dynamo.Graph.Nodes;
using Dynamo.Models;
using Dynamo.Visualization;

namespace DynamoWPFCLI
namespace Dynamo.Visualization
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
{
internal class GeometryData
{
Expand Down Expand Up @@ -100,7 +99,7 @@ public GeometryHolder(DynamoModel model, IRenderPackageFactory factory, NodeMode

// Schedule the generation of render packages for this node. NodeRenderPackagesUpdated will be
// called with the render packages when they are ready. The node will be set do 'Done' if the
// sheduling for some reason is not successful (usually becuase the node have no geometry or is inivisible)
// scheduling for some reason is not successful (usually because the node have no geometry or is invisible)
nodeModel.RenderPackagesUpdated += NodeRenderPackagesUpdated;
if (!nodeModel.RequestVisualUpdateAsync(model.Scheduler, model.EngineController, factory, true))
{
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
[assembly: InternalsVisibleTo("ViewExtensionLibraryTests")]
[assembly: InternalsVisibleTo("DynamoWPFCLI")]
[assembly: InternalsVisibleTo("CommandLineTests")]
[assembly: InternalsVisibleTo("Watch3DNodeModelsWpf")]
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ private void RegisterNodeEventHandlers(NodeModel node)
RegisterPortEventHandlers(node);
}

protected void UnregisterNodeEventHandlers(NodeModel node)
internal void UnregisterNodeEventHandlers(NodeModel node)
{
node.PropertyChanged -= OnNodePropertyChanged;
node.RenderPackagesUpdated -= OnRenderPackagesUpdated;
Expand Down
1 change: 0 additions & 1 deletion src/DynamoWPFCLI/DynamoWPFCLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<Link>AssemblySharedInfo.cs</Link>
</Compile>
<Compile Include="CommandLineRunnerWPF.cs" />
<Compile Include="GeometryHolder.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public HelixWatch3DNodeViewModel(Watch3D node, Watch3DViewModelStartupParams par
Name = string.Format("{0} Preview", node.GUID);
}

protected override void OnWatchExecution()
protected internal override void OnWatchExecution()
{
var watch3D = watchModel as Watch3D;
if (watch3D != null)
Expand All @@ -53,7 +53,7 @@ protected override void PortConnectedHandler(PortModel arg1, ConnectorModel arg2
UpdateUpstream();
}

protected override void UpdateUpstream()
protected internal override void UpdateUpstream()
{
OnClear();

Expand Down
1 change: 1 addition & 0 deletions test/DynamoCoreWpfTests/DynamoCoreWpfTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<Link>Properties\AssemblySharedInfo.cs</Link>
</Compile>
<Compile Include="ColorPaletteTests.cs" />
<Compile Include="GraphViewTests.cs" />
<Compile Include="ListAtLevelTest.cs" />
<Compile Include="NodeHelpPromptTest.cs" />
<Compile Include="NoteViewTests.cs" />
Expand Down
100 changes: 100 additions & 0 deletions test/DynamoCoreWpfTests/GraphViewTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System.Collections.Generic;
using System.Threading;
using Dynamo.Graph.Workspaces;
using Dynamo.Models;
using Dynamo.Visualization;
using Dynamo.Wpf.Rendering;
using DynamoCoreWpfTests.Utility;

namespace DynamoCoreWpfTests
{

/// <summary>
/// This class should not be used for DynamoView unit tests
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public class GrapViewTests : DynamoTestUIBase
{
/// <summary>
/// Signal used for performance time measurement
/// </summary>
private static ManualResetEvent signalEvent = new ManualResetEvent(false);

/// <summary>
/// Function used to measure file open which saved in manual mode
/// </summary>
/// <param name="path"></param>
public override void Open(string path)
{
base.Open(path);

DispatcherUtil.DoEvents();
}

/// <summary>
/// Call this to disable the event handler to get render package (Tessellation)
/// Rendering in helix view will also be disabled as a result of this
/// Currently only used in performance benchmarking
/// </summary>
public void DisableRendering()
{
// Dispose the background watch 3D ViewModel so no tessellation or rendering happen
foreach (var node in Model.CurrentWorkspace.Nodes)
{
ViewModel.BackgroundPreviewViewModel.UnregisterNodeEventHandlers(node);
}
}

/// <summary>
/// Event handler for EvaluationCompleted event
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">EvaluationCompletedEventArgs</param>
void OnGraphEvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
{
if (e.EvaluationSucceeded)
{
// Signal the signalEvent ready
signalEvent.Set();
}
}

/// <summary>
/// Function used to measure graph run with view
/// </summary>
public override void Run()
{
// A more precise way to measure the time spent is from when
// run() called to when even EvaluationCompleted is trigger on workspace
(Model.CurrentWorkspace as HomeWorkspaceModel).EvaluationCompleted += OnGraphEvaluationCompleted;

base.Run();
signalEvent.WaitOne();
signalEvent.Reset();
// Unsubscribe
(Model.CurrentWorkspace as HomeWorkspaceModel).EvaluationCompleted -= OnGraphEvaluationCompleted;
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Function used to measure graph geometry tessellation
/// </summary>
public void Tessellation()
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
var renderPackageFactory = new HelixRenderPackageFactory();

// A list of GeometryHolder for all the nodes belong to the graph
var nodeGeometries = new List<GeometryHolder>();

foreach (var node in Model.CurrentWorkspace.Nodes)
{
// Each Geometry Holder will request render packages and trigger Tessellation and Rendering
nodeGeometries.Add(new GeometryHolder(Model, renderPackageFactory, node));
}

foreach (var holder in nodeGeometries)
{
if (holder.HasGeometry)
continue;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace DynamoPerformanceTests
{

public class DynamoViewPerformanceTestBase : NodeViewTests
public class DynamoViewPerformanceTestBase : GrapViewTests
{
/// <summary>
/// Override this function to preload dlls into Dynamo library
Expand Down Expand Up @@ -60,7 +60,7 @@ public static IEnumerable<string> PerformanceTestSource()

#region Iteration setup and cleanup methods for Benchmarks
/// <summary>
/// Setup method to be called before each OpenModel benchmark.
/// Setup method to be called before each OpenGraph benchmark.
/// </summary>
[IterationSetup(Target = nameof(OpenGraph))]
public void IterationSetupOpenModelWithUI()
Expand All @@ -69,15 +69,34 @@ public void IterationSetupOpenModelWithUI()
}

/// <summary>
/// Setup method to be called before each RunModel benchmark.
/// Setup method to be called before each RunGraph benchmark.
/// </summary>
[IterationSetup(Target = nameof(RunGraph))]
public void IterationSetupRunModelWithUI()
{
Start();

// open the dyn file
Open(DynamoFilePath);

// Disable tessellation or rendering
DisableRendering();
}

/// <summary>
/// Setup method to be called before each RenderGraph benchmark.
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
[IterationSetup(Target = nameof(GraphTessellationAndRendering))]
public void IterationSetupRenderGraph()
{
Start();

//open the dyn file
Open(DynamoFilePath);
// Disable tessellation or rendering
DisableRendering();

Run();
}

/// <summary>
Expand Down Expand Up @@ -108,6 +127,12 @@ public void RunGraph()
Run();
}

[Benchmark, System.STAThread]
public void GraphTessellationAndRendering()
{
Tessellation();
}

#endregion
}
}