Browse Source

Performance test (in animation sample for simplicity). Test construction and destruction of elements.

Michael Ragazzon 6 years ago
parent
commit
18944434f6
2 changed files with 49 additions and 0 deletions
  1. 2 0
      Samples/basic/animation/data/animation.rml
  2. 47 0
      Samples/basic/animation/src/main.cpp

+ 2 - 0
Samples/basic/animation/data/animation.rml

@@ -174,6 +174,8 @@
 	<button id="exit" onclick="exit">Exit</button>
 </div>
 
+<div id="performance" style="bottom: 0; height: 30%; width: 20%; position: absolute;"/>
+
 <div style="width: 20%; height: 80%;position: absolute; left: 28%;" id="transform_tests">
 	<div style="font-size: 1.5em; text-align: left;">Test transform animations</div>
 	<div class="container"><div class="plain" id="generic">Generic form conversion.</div></div>

+ 47 - 0
Samples/basic/animation/src/main.cpp

@@ -128,6 +128,51 @@ public:
 		}
 	}
 
+	void performance_test()
+	{
+		/*
+		  FPS values
+		  Original: 18.5
+		  Without property counter: 22.0
+		
+		*/
+		if (!document)
+			return;
+
+		auto el = document->GetElementById("performance");
+
+		Rocket::Core::String rml;
+
+		for (int i = 0; i < 50; i++)
+		{
+			int index = rand() % 1000;
+			int route = rand() % 50;
+			int max = (rand() % 40) + 10;
+			int value = rand() % max;
+			Rocket::Core::String rml_row(1000, R"(
+			<div class="row">
+				<div class="col col1"><button class="expand" index="%d">+</button>&nbsp;<a>Route %d</a></div>
+				<div class="col col23"><input type="range" class="assign_range" min="0" max="%d" value="%d"/></div>
+				<div class="col col4">Assigned</div>
+				<div class="inrow unmark_collapse">
+					<div class="col col123 assign_text">Assign to route</div>
+					<div class="col col4">
+						<button class="vehicle_depot_assign_confirm" quantity="0">Confirm</button>
+					</div>
+				</div>
+			</div>)",
+				index, 
+				route,
+				max,
+				value
+			);
+			rml += rml_row;
+		}
+
+		if (el)
+			el->SetInnerRML(rml);
+	}
+
 	~DemoWindow()
 	{
 		if (document)
@@ -195,6 +240,8 @@ void GameLoop()
 		count_frames = 0;
 		el->SetInnerRML(Rocket::Core::String{ 20, "FPS: %f", fps });
 	}
+
+	window->performance_test();
 	//static int f_prev = 0.0f;
 	//int df = f - f_prev;
 	//f_prev = f;