summaryrefslogtreecommitdiff
path: root/share/scripts/_split_benchmark.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
committerRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
commit180843f9bd28b191c7404245ba0a121107992511 (patch)
treec60312dc09f76c2f55ba2383245c427e15c38dea /share/scripts/_split_benchmark.lua
parentbf649cd68ad46c34a656700aa6cb89416d648c64 (diff)
Also move Lua scripts to share subfolder
Diffstat (limited to 'share/scripts/_split_benchmark.lua')
-rw-r--r--share/scripts/_split_benchmark.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/share/scripts/_split_benchmark.lua b/share/scripts/_split_benchmark.lua
new file mode 100644
index 0000000000..6ab60e44bc
--- /dev/null
+++ b/share/scripts/_split_benchmark.lua
@@ -0,0 +1,58 @@
+-- [disable CPU freq scaling for benchmark]
+-- create a session
+-- add 16 mono tracks
+-- record 2-3 mins on each track starting at 00:00:00:00
+-- rewind the playhead to 00:00:00:00
+-- run this script in Menu > Window. Scripting 10 times
+ardour { ["type"] = "EditorAction", name = "Split Benchmark" }
+
+function factory (params) return function ()
+
+ function split_at (pos)
+ local add_undo = false -- keep track if something has changed
+ Session:begin_reversible_command ("Auto Region Split")
+ for route in Session:get_tracks():iter() do
+ local playlist = route:to_track():playlist ()
+ playlist:to_stateful ():clear_changes ()
+ for region in playlist:regions_at (pos):iter () do
+ playlist:split_region (region, ARDOUR.MusicSample (pos, 0))
+ end
+ if not Session:add_stateful_diff_command (playlist:to_statefuldestructible ()):empty () then
+ add_undo = true
+ end
+ end
+ if add_undo then
+ Session:commit_reversible_command (nil)
+ else
+ Session:abort_reversible_command ()
+ end
+ end
+
+ function count_regions ()
+ local total = 0
+ for route in Session:get_tracks():iter() do
+ total = total + route:to_track():playlist():region_list():size()
+ end
+ return total
+ end
+
+ for x = 1, 3 do
+ local playhead = Session:transport_sample ()
+
+ local step = Session:samples_per_timecode_frame()
+ local n_steps = 20
+
+ local t_start = ARDOUR.LuaAPI.monotonic_time ()
+ for i = 1, n_steps do
+ split_at (playhead + step * i)
+ end
+ local t_end = ARDOUR.LuaAPI.monotonic_time ()
+
+ Session:request_locate((playhead + step * n_steps), ARDOUR.LocateTransportDisposition.MustStop, ARDOUR.TransportRequestSource.TRS_UI)
+ print (count_regions (), (t_end - t_start) / 1000 / n_steps)
+ collectgarbage ();
+ ARDOUR.LuaAPI.usleep(500000)
+ end
+
+
+end end