vimamsa 0.1.26 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/appimage.yml +93 -0
- data/.gitignore +4 -1
- data/Dockerfile +7 -4
- data/README.md +195 -99
- data/custom_example.rb +59 -17
- data/doc/TODO.md +678 -0
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +570 -0
- data/doc/delta_syntax_plan.md +293 -0
- data/doc/demo_recording_plan.md +288 -0
- data/doc/design_goals.md +27 -0
- data/doc/intro_page_plan.md +266 -0
- data/doc/key_bindings_report_plan.md +213 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +61 -0
- data/doc/modules_settings_plan.md +433 -0
- data/doc/refactor_dedup_plan.md +117 -0
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/unused_code_plan.md +120 -0
- data/doc/vim_compatibility_plan.md +451 -0
- data/doc/vimlike_vim_conflicts.md +262 -0
- data/doc/vm_snapshots_plan.md +146 -0
- data/doc/wysiwyg_plan.md +231 -0
- data/exe/run_tests.rb +124 -3
- data/exe/vimamsa +68 -5
- data/fonts/OFL-Oxanium.txt +93 -0
- data/fonts/Oxanium[wght].ttf +0 -0
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/icon.png +0 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +7 -1
- data/lib/vimamsa/ack.rb +13 -1
- data/lib/vimamsa/actions.rb +385 -37
- data/lib/vimamsa/appimage_env.rb +35 -0
- data/lib/vimamsa/audio.rb +2 -5
- data/lib/vimamsa/bookmarks.rb +302 -0
- data/lib/vimamsa/buffer.rb +675 -118
- data/lib/vimamsa/buffer_changetext.rb +150 -68
- data/lib/vimamsa/buffer_cursor.rb +7 -0
- data/lib/vimamsa/buffer_list.rb +6 -2
- data/lib/vimamsa/buffer_manager.rb +10 -7
- data/lib/vimamsa/bundled_fonts.rb +32 -0
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +9 -3
- data/lib/vimamsa/conf.rb +68 -3
- data/lib/vimamsa/constants.rb +3 -0
- data/lib/vimamsa/crash_handler.rb +149 -0
- data/lib/vimamsa/debug.rb +6 -3
- data/lib/vimamsa/demo_player.rb +458 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/desktop_install.rb +96 -0
- data/lib/vimamsa/diff_buffer.rb +40 -11
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +57 -3
- data/lib/vimamsa/editor.rb +327 -78
- data/lib/vimamsa/encrypt.rb +78 -29
- data/lib/vimamsa/file_finder.rb +4 -19
- data/lib/vimamsa/file_history.rb +4 -1
- data/lib/vimamsa/file_manager.rb +46 -31
- data/lib/vimamsa/fold.rb +226 -0
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +603 -119
- data/lib/vimamsa/gui_command_line.rb +247 -0
- data/lib/vimamsa/gui_dialog.rb +94 -42
- data/lib/vimamsa/gui_file_panel.rb +356 -25
- data/lib/vimamsa/gui_form_generator.rb +75 -40
- data/lib/vimamsa/gui_func_panel.rb +67 -22
- data/lib/vimamsa/gui_image.rb +3 -0
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +408 -0
- data/lib/vimamsa/gui_menu.rb +84 -53
- data/lib/vimamsa/gui_select_window.rb +80 -75
- data/lib/vimamsa/gui_settings.rb +86 -41
- data/lib/vimamsa/gui_sourceview.rb +280 -92
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
- data/lib/vimamsa/gui_text.rb +63 -2
- data/lib/vimamsa/gui_theme.rb +615 -0
- data/lib/vimamsa/hook.rb +5 -0
- data/lib/vimamsa/hyper_plain_text.rb +3 -0
- data/lib/vimamsa/intro_page.rb +368 -0
- data/lib/vimamsa/key_actions.rb +382 -193
- data/lib/vimamsa/key_binding_tree.rb +467 -273
- data/lib/vimamsa/key_bindings_notepad.rb +45 -0
- data/lib/vimamsa/key_bindings_report.rb +484 -0
- data/lib/vimamsa/key_bindings_vim.rb +104 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +353 -289
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/langservp.rb +271 -54
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +23 -3
- data/lib/vimamsa/main.rb +14 -8
- data/lib/vimamsa/rbvma.rb +41 -1
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search.rb +3 -0
- data/lib/vimamsa/search_replace.rb +15 -14
- data/lib/vimamsa/string_util.rb +134 -40
- data/lib/vimamsa/terminal.rb +3 -0
- data/lib/vimamsa/test_framework.rb +28 -2
- data/lib/vimamsa/tests.rb +11 -8
- data/lib/vimamsa/text_objects.rb +310 -0
- data/lib/vimamsa/text_transforms.rb +18 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/util.rb +46 -7
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_core.rb +355 -0
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/lib/vimamsa.rb +0 -1
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +118 -0
- data/modules/color_highlight/color_highlight_info.rb +3 -0
- data/modules/dictation/dictation.rb +1054 -0
- data/modules/dictation/dictation_info.rb +3 -0
- data/modules/dictation/whisper_worker.py +273 -0
- data/modules/ollama/ollama.rb +107 -0
- data/modules/ollama/ollama_info.rb +3 -0
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +119 -0
- data/modules/tts/tts_info.rb +3 -0
- data/run_e2e_vm.sh +28 -0
- data/run_tests_vm.rb +138 -0
- data/scripts/appimage/AppRun +54 -0
- data/scripts/appimage/Dockerfile +18 -0
- data/scripts/appimage/build.sh +19 -0
- data/scripts/appimage/build_in_container.sh +192 -0
- data/scripts/appimage/smoke_test.sh +27 -0
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +67 -0
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +156 -0
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +29 -0
- data/scripts/demo/square/shapes.rb +29 -0
- data/scripts/demo/square/steps.txt +185 -0
- data/scripts/lib/perf_startup.rb +138 -0
- data/scripts/lib/script_helpers.rb +53 -0
- data/scripts/perf_compare.rb +34 -0
- data/scripts/profile_startup.rb +72 -0
- data/styles/134272-molokai.xml +3 -0
- data/styles/molokai_cyber.xml +48 -0
- data/styles/molokai_edit.xml +1 -0
- data/tests/support/virtual_keyboard.rb +254 -0
- data/tests/support/virtual_mic.rb +67 -0
- data/tests/test_ack.rb +22 -0
- data/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +122 -0
- data/tests/test_autocomplete.rb +211 -0
- data/tests/test_autosave.rb +145 -0
- data/tests/test_basic_editing.rb +46 -16
- data/tests/test_bookmarks.rb +206 -0
- data/tests/test_bracket_match.rb +88 -0
- data/tests/test_bundling.rb +92 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +92 -0
- data/tests/test_command_line.rb +79 -0
- data/tests/test_command_line_file.rb +27 -0
- data/tests/test_context_menu_file.rb +147 -0
- data/tests/test_copy_paste.rb +106 -26
- data/tests/test_crash_handler.rb +39 -0
- data/tests/test_custom_two_phase.rb +92 -0
- data/tests/test_demo_player.rb +301 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dialog_callback_errors.rb +44 -0
- data/tests/test_dictation.rb +294 -0
- data/tests/test_diff_buffer_name.rb +51 -0
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_double_click.rb +41 -0
- data/tests/test_drag_selection.rb +125 -0
- data/tests/test_e2e_cmdline.rb +116 -0
- data/tests/test_e2e_dictation.rb +98 -0
- data/tests/test_e2e_replace_char.rb +58 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +55 -0
- data/tests/test_file_format.rb +217 -0
- data/tests/test_file_manager.rb +72 -0
- data/tests/test_file_panel.rb +269 -0
- data/tests/test_flash.rb +78 -0
- data/tests/test_fold.rb +111 -0
- data/tests/test_font_refresh.rb +56 -0
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +68 -0
- data/tests/test_grep_apply.rb +46 -0
- data/tests/test_gtk_sync.rb +126 -0
- data/tests/test_hpt_highlight_visible.rb +75 -0
- data/tests/test_hpt_link_highlight.rb +82 -0
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_jump_to_file.rb +41 -0
- data/tests/test_key_bindings.rb +208 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +261 -0
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +281 -0
- data/tests/test_lsp_jump.rb +87 -0
- data/tests/test_lsp_position_encoding.rb +49 -0
- data/tests/test_lsp_symbols.rb +68 -0
- data/tests/test_macro.rb +137 -0
- data/tests/test_markdown_highlight.rb +57 -0
- data/tests/test_mode_badge.rb +41 -0
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +67 -0
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_popup_queue.rb +51 -0
- data/tests/test_random_edit.rb +109 -0
- data/tests/test_registers.rb +122 -0
- data/tests/test_revert.rb +127 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +58 -0
- data/tests/test_status_area.rb +50 -0
- data/tests/test_text_objects.rb +163 -0
- data/tests/test_text_transforms.rb +341 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +68 -0
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +353 -0
- data/tests/test_vim_conflicts.rb +100 -0
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +302 -0
- data/vimamsa.gemspec +3 -1
- data/vm_guest_run.sh +129 -0
- metadata +167 -10
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Records a demo as an animation (default: the README's img/demo.gif) on
|
|
3
|
+
# this machine: runs the editor from this checkout on a hidden X display
|
|
4
|
+
# (Xvfb, so the desktop isn't disturbed), lets the editor's own demo player
|
|
5
|
+
# (lib/vimamsa/demo_player.rb) play the steps file, records the window with
|
|
6
|
+
# ffmpeg and converts the video to an optimized GIF. The player feeds the
|
|
7
|
+
# keys to the key bindings as if typed (the key log panel shows them), finds
|
|
8
|
+
# easy jump labels for this window, and types into forms and list windows.
|
|
9
|
+
#
|
|
10
|
+
# ruby scripts/demo/record_demo.rb [STEPS] [--speed 0.7] [--out img/demo.gif] [--keep]
|
|
11
|
+
# STEPS the steps file (default scripts/demo/demo_steps.txt), e.g.
|
|
12
|
+
# scripts/demo/square/steps.txt or a recorded demo in
|
|
13
|
+
# ~/.config/vimamsa/demos/<name>/steps.txt. Its files ("file"
|
|
14
|
+
# lines, default shapes.rb) are taken from its folder.
|
|
15
|
+
# --speed playback speed: every delay and wait in the steps file is
|
|
16
|
+
# divided by it (1 = as written, 0.5 = twice as slow).
|
|
17
|
+
# Default 0.7, as the editor's Help > Demos at 1x.
|
|
18
|
+
# --size the editor window's size, WIDTHxHEIGHT (default 960x600). A
|
|
19
|
+
# smaller window shows fewer lines: easy jump targets off
|
|
20
|
+
# screen are reached without a label.
|
|
21
|
+
# --keep also keep the lossless video (build/demo/demo.mkv)
|
|
22
|
+
#
|
|
23
|
+
# Needs: Xvfb, xdotool, ffmpeg, gifsicle.
|
|
24
|
+
require "fileutils"
|
|
25
|
+
require "tmpdir"
|
|
26
|
+
require "optparse"
|
|
27
|
+
|
|
28
|
+
ROOT = File.expand_path("../..", __dir__)
|
|
29
|
+
DIR = __dir__
|
|
30
|
+
FPS = 15
|
|
31
|
+
GIF_FPS = 12
|
|
32
|
+
opts = { out: File.join(ROOT, "img/demo.gif"), keep: false, speed: 0.7, size: "960x600" }
|
|
33
|
+
OptionParser.new { |o|
|
|
34
|
+
o.on("--speed FACTOR", Float) { |v| opts[:speed] = v }
|
|
35
|
+
o.on("--size WxH") { |v| opts[:size] = v }
|
|
36
|
+
o.on("--out PATH") { |v| opts[:out] = File.expand_path(v) }
|
|
37
|
+
o.on("--keep") { opts[:keep] = true }
|
|
38
|
+
}.parse!
|
|
39
|
+
abort "--speed must be > 0" unless opts[:speed] > 0
|
|
40
|
+
SPEED = opts[:speed]
|
|
41
|
+
WIDTH, HEIGHT = opts[:size].split("x").map(&:to_i)
|
|
42
|
+
abort "--size must be WIDTHxHEIGHT, e.g. 960x600" unless WIDTH.to_i > 0 && HEIGHT.to_i > 0
|
|
43
|
+
STEPS = File.expand_path(ARGV[0] || File.join(DIR, "demo_steps.txt"))
|
|
44
|
+
abort "steps file not found: #{STEPS}" unless File.file?(STEPS)
|
|
45
|
+
SRC = File.dirname(STEPS)
|
|
46
|
+
FILES = File.readlines(STEPS, chomp: true).filter_map { |l| l[/\Afile\s+(\S+)/, 1] }
|
|
47
|
+
FILES << "shapes.rb" if FILES.empty?
|
|
48
|
+
FILES.each { |f| abort "#{f} (a file of the demo) not found in #{SRC}" unless File.file?(File.join(SRC, f)) }
|
|
49
|
+
|
|
50
|
+
%w[Xvfb xdotool ffmpeg gifsicle].each { |t|
|
|
51
|
+
abort "#{t} not found (sudo apt install xvfb xdotool ffmpeg gifsicle)" unless system("which #{t} >/dev/null")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
WORK = File.join(ROOT, "build/demo")
|
|
55
|
+
FileUtils.mkdir_p(WORK)
|
|
56
|
+
pids = []
|
|
57
|
+
at_exit { pids.reverse_each { |pid| Process.kill("TERM", pid) rescue nil; Process.wait(pid) rescue nil } }
|
|
58
|
+
|
|
59
|
+
def sh!(*cmd)
|
|
60
|
+
system(*cmd) or abort "failed: #{cmd.join(" ")}"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# ── Hidden X display. The editor's first-start size is 90% of the screen, so
|
|
64
|
+
# this screen gives a WIDTH x HEIGHT window. ──
|
|
65
|
+
display = (90..99).find { |n| !File.exist?("/tmp/.X#{n}-lock") } or abort "no free X display"
|
|
66
|
+
disp = ":#{display}"
|
|
67
|
+
screen = "#{(WIDTH / 0.9).ceil}x#{(HEIGHT / 0.9).ceil}x24"
|
|
68
|
+
pids << spawn("Xvfb", disp, "-screen", "0", screen, "-nolisten", "tcp", out: File::NULL, err: File::NULL)
|
|
69
|
+
sleep 0.2 until File.exist?("/tmp/.X11-unix/X#{display}")
|
|
70
|
+
|
|
71
|
+
env = { "DISPLAY" => disp, "GDK_BACKEND" => "x11", "WAYLAND_DISPLAY" => nil,
|
|
72
|
+
"GTK_THEME" => nil, "NO_AT_BRIDGE" => "1" }
|
|
73
|
+
|
|
74
|
+
# ── The editor, with a throwaway config dir: default settings, no intro
|
|
75
|
+
# page, nothing read from or written to the user's own config. Its
|
|
76
|
+
# custom.rb plays the demo once ready + go (files in the config dir), then
|
|
77
|
+
# writes done and quits. ──
|
|
78
|
+
ud = Dir.mktmpdir("vma-demo")
|
|
79
|
+
at_exit { FileUtils.rm_rf(ud) }
|
|
80
|
+
ready, go, done = %w[ready go done].map { |f| File.join(ud, f) }
|
|
81
|
+
demo = { steps: STEPS, files: FILES, src: SRC }
|
|
82
|
+
File.write(File.join(ud, "custom.rb"), <<~RUBY)
|
|
83
|
+
cnf.lsp.enabled = false
|
|
84
|
+
cnf.intro.show_on_startup = false
|
|
85
|
+
def hook_custom_after_init
|
|
86
|
+
vma.gui.show_keylog_panel
|
|
87
|
+
File.write(#{ready.inspect}, "1")
|
|
88
|
+
GLib::Timeout.add(100) {
|
|
89
|
+
next true if !File.exist?(#{go.inspect})
|
|
90
|
+
DemoPlayer.new(:recording, demo: #{demo.inspect}, speed: #{SPEED}, rate: 1, loop: false, controls: false,
|
|
91
|
+
on_finish: proc { |msg|
|
|
92
|
+
# written whole, then renamed: the script never reads it half done
|
|
93
|
+
File.write(#{(done + ".tmp").inspect}, msg.to_s)
|
|
94
|
+
File.rename(#{(done + ".tmp").inspect}, #{done.inspect})
|
|
95
|
+
GLib::Timeout.add(1000) { vma.shutdown; false }
|
|
96
|
+
}).start
|
|
97
|
+
false
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
RUBY
|
|
101
|
+
editor = spawn(env, RbConfig.ruby, File.join(ROOT, "exe/vimamsa"), "--user-dir", ud,
|
|
102
|
+
chdir: "/tmp", out: File.join(WORK, "editor.log"), err: [:child, :out])
|
|
103
|
+
pids << editor
|
|
104
|
+
|
|
105
|
+
def xdo(env, *args)
|
|
106
|
+
out = IO.popen(env, ["xdotool", *args], err: File::NULL, &:read)
|
|
107
|
+
$?.success? ? out : nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
win = nil
|
|
111
|
+
60.times {
|
|
112
|
+
win = xdo(env, "search", "--onlyvisible", "--name", "^Vimamsa")&.split&.last
|
|
113
|
+
break if win && File.exist?(ready)
|
|
114
|
+
sleep 0.5
|
|
115
|
+
}
|
|
116
|
+
abort "editor window did not appear (log: #{WORK}/editor.log)" unless win && File.exist?(ready)
|
|
117
|
+
sleep 2 # first layout, highlighting, key log panel
|
|
118
|
+
xdo(env, "windowfocus", "--sync", win)
|
|
119
|
+
geo = xdo(env, "getwindowgeometry", "--shell", win).scan(/(\w+)=(\d+)/).to_h.transform_values(&:to_i)
|
|
120
|
+
x, y = geo["X"], geo["Y"]
|
|
121
|
+
w, h = geo["WIDTH"] & ~1, geo["HEIGHT"] & ~1 # even sizes for the encoder
|
|
122
|
+
puts "window #{w}x#{h} at #{x},#{y}; playing #{STEPS}"
|
|
123
|
+
|
|
124
|
+
# ── Record ──
|
|
125
|
+
video = File.join(WORK, "demo.mkv")
|
|
126
|
+
rec = spawn("ffmpeg", "-loglevel", "warning", "-nostdin", "-y", "-f", "x11grab", "-framerate", FPS.to_s,
|
|
127
|
+
"-video_size", "#{w}x#{h}", "-draw_mouse", "0", "-i", "#{disp}+#{x},#{y}",
|
|
128
|
+
"-c:v", "libx264rgb", "-crf", "0", "-preset", "ultrafast", video)
|
|
129
|
+
sleep 0.5
|
|
130
|
+
File.write(go, "1")
|
|
131
|
+
t = Time.now
|
|
132
|
+
sleep 0.2 until File.exist?(done) || Process.waitpid(editor, Process::WNOHANG) || Time.now - t > 1800
|
|
133
|
+
msg = File.exist?(done) ? File.read(done) : "editor quit or timed out (log: #{WORK}/editor.log)"
|
|
134
|
+
sleep 0.8 # the end state on screen for a moment
|
|
135
|
+
Process.kill("INT", rec)
|
|
136
|
+
Process.wait(rec)
|
|
137
|
+
abort "the demo didn't finish: #{msg}" unless msg == "Demo finished"
|
|
138
|
+
# ffmpeg exits 255 when stopped with INT; anything else is an error
|
|
139
|
+
abort "recording failed (ffmpeg exit #{$?.exitstatus})" unless [0, 255].include?($?.exitstatus)
|
|
140
|
+
system("ffmpeg", "-v", "error", "-i", video, "-f", "null", "-", err: File.join(WORK, "decode.log"))
|
|
141
|
+
abort "the recorded video is damaged: #{File.read(File.join(WORK, "decode.log"))[0, 300]}" unless File.size(File.join(WORK, "decode.log")).zero?
|
|
142
|
+
|
|
143
|
+
# ── GIF: one palette for the whole clip, only changed rectangles stored ──
|
|
144
|
+
palette = File.join(WORK, "palette.png")
|
|
145
|
+
filters = "fps=#{GIF_FPS}"
|
|
146
|
+
sh!("ffmpeg", "-loglevel", "error", "-y", "-i", video,
|
|
147
|
+
"-vf", "#{filters},palettegen=max_colors=128:stats_mode=diff", palette)
|
|
148
|
+
raw_gif = File.join(WORK, "demo_raw.gif")
|
|
149
|
+
sh!("ffmpeg", "-loglevel", "error", "-y", "-i", video, "-i", palette, "-lavfi",
|
|
150
|
+
"#{filters}[v];[v][1:v]paletteuse=dither=none:diff_mode=rectangle", raw_gif)
|
|
151
|
+
FileUtils.mkdir_p(File.dirname(opts[:out]))
|
|
152
|
+
sh!("gifsicle", "-O3", "--lossy=30", "-o", opts[:out], raw_gif)
|
|
153
|
+
FileUtils.rm_f([palette, raw_gif])
|
|
154
|
+
FileUtils.rm_f(video) unless opts[:keep]
|
|
155
|
+
dur = IO.popen(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", opts[:out]], &:read).to_f
|
|
156
|
+
puts "wrote #{opts[:out]} at speed #{SPEED} (#{(File.size(opts[:out]) / 1024.0 / 1024).round(2)} MB, #{dur.round(1)} s)"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Example file for the README demo
|
|
2
|
+
class Shape
|
|
3
|
+
def initialize(name)
|
|
4
|
+
@name = name
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def area
|
|
8
|
+
0
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
"#{@name}: #{area.round(2)}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Circle < Shape
|
|
17
|
+
def initialize(radius)
|
|
18
|
+
super("circle")
|
|
19
|
+
@radius = radius
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def area
|
|
23
|
+
Math::PI * @radius**2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
shapes = [Circle.new(1), Circle.new(2.5)]
|
|
28
|
+
shapes.each { |s| puts s }
|
|
29
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Example file for the README demo
|
|
2
|
+
class Shape
|
|
3
|
+
def initialize(name)
|
|
4
|
+
@name = name
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def area
|
|
8
|
+
0
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
"#{@name}: #{area.round(2)}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Circle < Shape
|
|
17
|
+
def initialize(radius)
|
|
18
|
+
super("circle")
|
|
19
|
+
@radius = radius
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def area
|
|
23
|
+
Math::PI * @radius**2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
shapes = [Circle.new(1), Circle.new(2.5)]
|
|
28
|
+
shapes.each { |s| puts s }
|
|
29
|
+
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Recorded with Help ▸ Demos ▸ Record demo (2026-11-21).
|
|
2
|
+
# Edit freely; the format is in scripts/demo/demo_steps.txt.
|
|
3
|
+
title square
|
|
4
|
+
file shapes.rb
|
|
5
|
+
delay 0.3
|
|
6
|
+
wait 0.3
|
|
7
|
+
# Jump to the start of the next word
|
|
8
|
+
keys w d
|
|
9
|
+
wait 1
|
|
10
|
+
# Delete to end of line (vim D), Switch to INSERT mode
|
|
11
|
+
keys O ctrl
|
|
12
|
+
type Hello World!!!
|
|
13
|
+
# Return to the previous mode
|
|
14
|
+
keys ctrl
|
|
15
|
+
# Move to the beginning of the current line
|
|
16
|
+
wait 0.5
|
|
17
|
+
keys 0
|
|
18
|
+
wait 0.2
|
|
19
|
+
# Move one line forward, Enter VISUAL mode (for selections), Move to the end of the buffer, Search actions
|
|
20
|
+
keys j v
|
|
21
|
+
delay 0.3
|
|
22
|
+
keys G
|
|
23
|
+
delay 0.3
|
|
24
|
+
keys , , s
|
|
25
|
+
wait 0.3
|
|
26
|
+
# A namespace and a fuzzy name: always the same action (the ranking of a
|
|
27
|
+
# plain fuzzy query depends on which actions exist)
|
|
28
|
+
type linerempempty
|
|
29
|
+
wait 0.5
|
|
30
|
+
# Form: submit, or press the focused button
|
|
31
|
+
keys enter
|
|
32
|
+
wait 0.5
|
|
33
|
+
# Move one line backward
|
|
34
|
+
keys k
|
|
35
|
+
wait 0.5
|
|
36
|
+
keys G
|
|
37
|
+
wait 0.2
|
|
38
|
+
keys X X X X
|
|
39
|
+
# Easy jump
|
|
40
|
+
keys s
|
|
41
|
+
target line 13 col 1
|
|
42
|
+
keys @JUMP_LABEL@
|
|
43
|
+
# Enter VISUAL mode (for selections)
|
|
44
|
+
keys v
|
|
45
|
+
# Easy jump
|
|
46
|
+
keys s
|
|
47
|
+
wait 0.4
|
|
48
|
+
target line 21 col 1
|
|
49
|
+
keys @JUMP_LABEL@
|
|
50
|
+
# Move to the end of the current line, Move backward one character, Copy selection to clipboard
|
|
51
|
+
keys O
|
|
52
|
+
delay 0.2
|
|
53
|
+
keys y
|
|
54
|
+
delay 0.2
|
|
55
|
+
keys h y
|
|
56
|
+
wait 0.5
|
|
57
|
+
# Insert an empty line below, Move one line backward, Paste text after the cursor
|
|
58
|
+
keys X X k X p
|
|
59
|
+
wait 0.5
|
|
60
|
+
# Easy jump
|
|
61
|
+
keys s
|
|
62
|
+
wait 0.3
|
|
63
|
+
target line 22 col 7
|
|
64
|
+
keys @JUMP_LABEL@
|
|
65
|
+
# Delete to the end of the word, Switch to INSERT mode
|
|
66
|
+
keys d e i
|
|
67
|
+
type Square
|
|
68
|
+
# Return to the previous mode
|
|
69
|
+
keys esc
|
|
70
|
+
wait 0.5
|
|
71
|
+
# Move one line forward, Move to the beginning of the current line, Enter VISUAL mode (for selections)
|
|
72
|
+
keys j 0 v
|
|
73
|
+
# Easy jump
|
|
74
|
+
keys s
|
|
75
|
+
wait 0.5
|
|
76
|
+
target line 30 col 1
|
|
77
|
+
keys @JUMP_LABEL@
|
|
78
|
+
# Move to the end of the current line, Move backward one character
|
|
79
|
+
keys O h , , r
|
|
80
|
+
wait 0.5
|
|
81
|
+
keys ,
|
|
82
|
+
wait 0.5
|
|
83
|
+
# Search and replace
|
|
84
|
+
keys r r
|
|
85
|
+
wait 0.5
|
|
86
|
+
type radius
|
|
87
|
+
# Form: next field or button
|
|
88
|
+
keys tab
|
|
89
|
+
type width
|
|
90
|
+
wait 0.4
|
|
91
|
+
# Form: submit, or press the focused button
|
|
92
|
+
keys enter
|
|
93
|
+
wait 0.5
|
|
94
|
+
# Move one line backward, Jump to the end of the next word
|
|
95
|
+
keys k k e
|
|
96
|
+
wait 0.5
|
|
97
|
+
target line 28 col 5
|
|
98
|
+
keys @JUMP_LABEL@
|
|
99
|
+
# Jump to the start of the previous word, Delete up to the next *, Delete char forward
|
|
100
|
+
keys d f *
|
|
101
|
+
wait 0.4
|
|
102
|
+
keys x
|
|
103
|
+
wait 0.2
|
|
104
|
+
# Move one line forward
|
|
105
|
+
keys j j
|
|
106
|
+
wait 0.2
|
|
107
|
+
keys j j j
|
|
108
|
+
wait 0.2
|
|
109
|
+
keys z z
|
|
110
|
+
wait 0.2
|
|
111
|
+
# Move one line backward, Jump to the start of the next word, Enter VISUAL mode (for selections), Move forward one character, Jump to the next ,, Move backward one character, Copy selection to clipboard, Move one line forward, Insert an empty line below, Paste text after the cursor, Move to the beginning of the current line, Copy the current line
|
|
112
|
+
keys w
|
|
113
|
+
wait 0.2
|
|
114
|
+
keys v l
|
|
115
|
+
wait 0.2
|
|
116
|
+
keys f , h
|
|
117
|
+
wait 0.2
|
|
118
|
+
keys y
|
|
119
|
+
wait 0.1
|
|
120
|
+
keys j
|
|
121
|
+
wait 0.2
|
|
122
|
+
keys X X
|
|
123
|
+
wait 0.2
|
|
124
|
+
keys p 0
|
|
125
|
+
wait 0.2
|
|
126
|
+
keys y y
|
|
127
|
+
wait 0.5
|
|
128
|
+
# Move to the end of the current line, Switch to INSERT mode
|
|
129
|
+
keys esc O i
|
|
130
|
+
type .area
|
|
131
|
+
# Return to the previous mode, Move to the beginning of the current line, Copy the current line, Paste text after the cursor
|
|
132
|
+
keys esc 0 y y p
|
|
133
|
+
wait 0.5
|
|
134
|
+
# Delete to the end of the word, Switch to INSERT mode
|
|
135
|
+
keys d e i
|
|
136
|
+
type AS
|
|
137
|
+
wait 0.3
|
|
138
|
+
# Delete backwards
|
|
139
|
+
keys backspace backspace
|
|
140
|
+
type Square
|
|
141
|
+
# Return to the previous mode
|
|
142
|
+
keys esc
|
|
143
|
+
wait 0.5
|
|
144
|
+
# Move one line backward
|
|
145
|
+
keys k
|
|
146
|
+
wait 0.5
|
|
147
|
+
# Join the next line to the current line, Move backward one character, Insert ,, Move to the beginning of the current line, Switch to INSERT mode
|
|
148
|
+
keys J h
|
|
149
|
+
wait 0.2
|
|
150
|
+
keys space ,
|
|
151
|
+
wait 0.2
|
|
152
|
+
keys 0
|
|
153
|
+
wait 0.2
|
|
154
|
+
keys i
|
|
155
|
+
type [
|
|
156
|
+
# Move to the end of the current line
|
|
157
|
+
keys ctrl-e
|
|
158
|
+
wait 0.5
|
|
159
|
+
type ]
|
|
160
|
+
wait 0.5
|
|
161
|
+
# Move to the beginning of the current line
|
|
162
|
+
keys ctrl-a
|
|
163
|
+
wait 1.1
|
|
164
|
+
# Return to the previous mode
|
|
165
|
+
keys esc
|
|
166
|
+
wait 1.1
|
|
167
|
+
# Move to the start of the buffer, Enter VISUAL mode (for selections), Move to the end of the buffer, Search actions
|
|
168
|
+
keys g g
|
|
169
|
+
wait 0.2
|
|
170
|
+
keys v G
|
|
171
|
+
wait 0.2
|
|
172
|
+
keys k k k
|
|
173
|
+
wait 0.2
|
|
174
|
+
keys , , s
|
|
175
|
+
wait 0.3
|
|
176
|
+
type evlalconver
|
|
177
|
+
wait 0.5
|
|
178
|
+
# Form: submit, or press the focused button
|
|
179
|
+
keys enter
|
|
180
|
+
wait 0.5
|
|
181
|
+
# Move one line forward
|
|
182
|
+
keys j j
|
|
183
|
+
wait 0.5
|
|
184
|
+
|
|
185
|
+
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Startup time of the editor, for comparing two versions (a performance
|
|
2
|
+
# regression check). Used by tests/test_perf_startup.rb and
|
|
3
|
+
# scripts/perf_compare.rb. Standard library only.
|
|
4
|
+
#
|
|
5
|
+
# Startup time = from starting exe/vimamsa until the editor has finished
|
|
6
|
+
# initializing (hook_custom_after_init, called at the end of Editor#start)
|
|
7
|
+
# and the main loop has run once (first idle), measured with the system-wide
|
|
8
|
+
# monotonic clock. Each version runs with its own throwaway config dir and the
|
|
9
|
+
# same file to open. Runs alternate between the versions, after a warm-up run
|
|
10
|
+
# of each, so a slow moment of the machine affects both. Versions are
|
|
11
|
+
# compared by their fastest run: other work on the machine only ever makes a
|
|
12
|
+
# run slower, so the fastest one is the least disturbed (the median is
|
|
13
|
+
# reported too).
|
|
14
|
+
require "tmpdir"
|
|
15
|
+
require "fileutils"
|
|
16
|
+
require "open3"
|
|
17
|
+
require "rbconfig"
|
|
18
|
+
|
|
19
|
+
module PerfStartup
|
|
20
|
+
module_function
|
|
21
|
+
|
|
22
|
+
def now
|
|
23
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A config dir whose custom.rb writes the time to <dir>/ready when the
|
|
27
|
+
# editor is up, and quits
|
|
28
|
+
def make_user_dir(dir)
|
|
29
|
+
FileUtils.mkdir_p(dir)
|
|
30
|
+
File.write(File.join(dir, "custom.rb"), <<~RUBY)
|
|
31
|
+
cnf.lsp.enabled = false
|
|
32
|
+
cnf.intro.show_on_startup = false # the same work as in older versions
|
|
33
|
+
def hook_custom_after_init
|
|
34
|
+
GLib::Idle.add {
|
|
35
|
+
File.write(#{File.join(dir, "ready").inspect}, Process.clock_gettime(Process::CLOCK_MONOTONIC).to_s)
|
|
36
|
+
GLib::Timeout.add(300) { vma.shutdown; false }
|
|
37
|
+
false
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
RUBY
|
|
41
|
+
dir
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Seconds until the editor in tree (a source checkout) was up
|
|
45
|
+
def startup_time(tree, user_dir, file: nil, timeout: 90)
|
|
46
|
+
ready = File.join(user_dir, "ready")
|
|
47
|
+
FileUtils.rm_f(ready)
|
|
48
|
+
t0 = now
|
|
49
|
+
pid = Process.spawn(RbConfig.ruby, File.join(tree, "exe/vimamsa"), "--user-dir", user_dir, *[file].compact,
|
|
50
|
+
out: File::NULL, err: File.join(user_dir, "log.txt"))
|
|
51
|
+
t = nil
|
|
52
|
+
loop {
|
|
53
|
+
if File.exist?(ready) && (s = File.read(ready)) != ""
|
|
54
|
+
t = s.to_f - t0
|
|
55
|
+
break
|
|
56
|
+
end
|
|
57
|
+
if Process.waitpid(pid, Process::WNOHANG)
|
|
58
|
+
pid = nil
|
|
59
|
+
raise "editor in #{tree} quit before it was up (log: #{user_dir}/log.txt)"
|
|
60
|
+
end
|
|
61
|
+
raise "editor in #{tree} not up after #{timeout} s (log: #{user_dir}/log.txt)" if now - t0 > timeout
|
|
62
|
+
sleep 0.01
|
|
63
|
+
}
|
|
64
|
+
# Let it quit by itself (custom.rb shuts it down)
|
|
65
|
+
t1 = now
|
|
66
|
+
while pid && Process.waitpid(pid, Process::WNOHANG).nil?
|
|
67
|
+
if now - t1 > 20
|
|
68
|
+
Process.kill("KILL", pid)
|
|
69
|
+
Process.wait(pid)
|
|
70
|
+
end
|
|
71
|
+
sleep 0.05
|
|
72
|
+
end
|
|
73
|
+
pid = nil
|
|
74
|
+
t
|
|
75
|
+
ensure
|
|
76
|
+
if pid
|
|
77
|
+
Process.kill("KILL", pid) rescue nil
|
|
78
|
+
Process.wait(pid) rescue nil
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Yields a checkout of ref (a temporary git worktree of repo). It gets this
|
|
83
|
+
# tree's compiled extension (lib/vmaext.so): its source isn't tracked, so
|
|
84
|
+
# an old commit can't be built.
|
|
85
|
+
def with_checkout(repo, ref)
|
|
86
|
+
dir = Dir.mktmpdir("vma-perf-ref")
|
|
87
|
+
FileUtils.rmdir(dir)
|
|
88
|
+
out, st = Open3.capture2e("git", "-C", repo, "worktree", "add", "--detach", "--force", dir, ref)
|
|
89
|
+
raise "git worktree add #{ref} failed: #{out}" if !st.success?
|
|
90
|
+
so = File.join(repo, "lib", "vmaext.so")
|
|
91
|
+
FileUtils.cp(so, File.join(dir, "lib")) if File.exist?(so)
|
|
92
|
+
yield dir
|
|
93
|
+
ensure
|
|
94
|
+
if dir && File.exist?(dir)
|
|
95
|
+
system("git", "-C", repo, "worktree", "remove", "--force", dir, out: File::NULL, err: File::NULL)
|
|
96
|
+
FileUtils.rm_rf(dir)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# { "current" => [seconds...], ref => [...] } for runs startups of each
|
|
101
|
+
def compare(repo, ref, runs: 5, file: nil, log: ->(s) { puts s })
|
|
102
|
+
Dir.mktmpdir("vma-perf") { |tmp|
|
|
103
|
+
with_checkout(repo, ref) { |old|
|
|
104
|
+
trees = { "current" => repo, ref => old }
|
|
105
|
+
dirs = trees.to_h { |name, _| [name, make_user_dir(File.join(tmp, name.gsub(/\W/, "_")))] }
|
|
106
|
+
times = trees.to_h { |name, _| [name, []] }
|
|
107
|
+
trees.each { |name, tree| startup_time(tree, dirs[name], file: file) } # warm-up
|
|
108
|
+
runs.times { |i|
|
|
109
|
+
trees.each { |name, tree|
|
|
110
|
+
t = startup_time(tree, dirs[name], file: file)
|
|
111
|
+
times[name] << t
|
|
112
|
+
log.(" run #{i + 1} #{name}: #{format("%.2f", t)} s")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
times
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def median(a)
|
|
121
|
+
s = a.sort
|
|
122
|
+
s.size.odd? ? s[s.size / 2] : (s[s.size / 2 - 1] + s[s.size / 2]) / 2.0
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# The commit to compare with by default: the previous one, or the current
|
|
126
|
+
# commit when the working tree has uncommitted changes to the code (then
|
|
127
|
+
# those changes are what's being checked)
|
|
128
|
+
def default_ref(repo)
|
|
129
|
+
out, = Open3.capture2("git", "-C", repo, "status", "--porcelain", "--", "lib", "exe", "ext")
|
|
130
|
+
out.strip.empty? ? "HEAD~1" : "HEAD"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Slower = the median grew by more than ratio and by more than min_secs
|
|
134
|
+
# (small absolute changes are noise)
|
|
135
|
+
def slower?(cur, ref, ratio: 0.25, min_secs: 0.3)
|
|
136
|
+
cur - ref > ref * ratio && cur - ref > min_secs
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Helpers shared by the project's Ruby scripts (run_tests_vm.rb, ...).
|
|
2
|
+
# Standard library only: the scripts run before any gems are installed.
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
5
|
+
module ScriptHelpers
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
# Print a step, as ">> msg"
|
|
9
|
+
def step(msg)
|
|
10
|
+
puts ">> #{msg}"
|
|
11
|
+
$stdout.flush
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Print an error, as "!! msg" (more lines indented), and exit with code
|
|
15
|
+
def fail!(msg, code = 1)
|
|
16
|
+
lines = msg.to_s.lines.map(&:chomp)
|
|
17
|
+
warn "!! #{lines.first}"
|
|
18
|
+
lines.drop(1).each { |l| warn " #{l}" }
|
|
19
|
+
exit code
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Run a command; on failure, exit with a message. label: what to call the
|
|
23
|
+
# command in the message (never the arguments, which may hold secrets).
|
|
24
|
+
def run!(*cmd, label: cmd.first, code: 1, **opts)
|
|
25
|
+
system(*cmd, **opts) || fail!("#{label} failed (exit #{$?.exitstatus})", code)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Run a command, printing its output (stdout and stderr) as it comes, and
|
|
29
|
+
# return [output, Process::Status]
|
|
30
|
+
def run_streaming(*cmd)
|
|
31
|
+
out = +""
|
|
32
|
+
status = nil
|
|
33
|
+
Open3.popen2e(*cmd) { |stdin, oe, thr|
|
|
34
|
+
stdin.close
|
|
35
|
+
begin
|
|
36
|
+
loop {
|
|
37
|
+
chunk = oe.readpartial(4096)
|
|
38
|
+
$stdout.write(chunk)
|
|
39
|
+
$stdout.flush
|
|
40
|
+
out << chunk
|
|
41
|
+
}
|
|
42
|
+
rescue EOFError
|
|
43
|
+
end
|
|
44
|
+
status = thr.value
|
|
45
|
+
}
|
|
46
|
+
[out, status]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The names of the environment variables that are unset or empty
|
|
50
|
+
def missing_env(*names)
|
|
51
|
+
names.select { |n| ENV[n].to_s.empty? }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Compare the editor's startup time with an earlier commit, on this machine
|
|
3
|
+
# (the same check as tests/test_perf_startup.rb, without the test runner).
|
|
4
|
+
# Opens editor windows on the current display, one after another.
|
|
5
|
+
#
|
|
6
|
+
# ruby scripts/perf_compare.rb [--ref REF] [--runs N]
|
|
7
|
+
# --ref commit to compare with (default: the previous commit, or the
|
|
8
|
+
# current one when lib/, exe/ or ext/ have uncommitted changes)
|
|
9
|
+
# --runs startups of each version (default 5)
|
|
10
|
+
#
|
|
11
|
+
# Exit code: 0 ok, 1 the current version starts much slower (fastest run
|
|
12
|
+
# more than 25% and 0.3 s slower).
|
|
13
|
+
require "optparse"
|
|
14
|
+
require_relative "lib/perf_startup"
|
|
15
|
+
require_relative "lib/script_helpers"
|
|
16
|
+
include ScriptHelpers
|
|
17
|
+
|
|
18
|
+
repo = File.expand_path("..", __dir__)
|
|
19
|
+
opts = { ref: nil, runs: 5 }
|
|
20
|
+
OptionParser.new { |o|
|
|
21
|
+
o.on("--ref REF") { |v| opts[:ref] = v }
|
|
22
|
+
o.on("--runs N", Integer) { |v| opts[:runs] = v }
|
|
23
|
+
}.parse!
|
|
24
|
+
fail!("--runs must be at least 1", 2) if opts[:runs] < 1
|
|
25
|
+
fail!("needs a display (DISPLAY or WAYLAND_DISPLAY)", 2) if missing_env("DISPLAY", "WAYLAND_DISPLAY").size == 2
|
|
26
|
+
ref = opts[:ref] || PerfStartup.default_ref(repo)
|
|
27
|
+
|
|
28
|
+
step "Startup time: current vs #{ref}, #{opts[:runs]} runs each"
|
|
29
|
+
times = PerfStartup.compare(repo, ref, runs: opts[:runs], file: File.join(repo, "README.md"))
|
|
30
|
+
cur, old = times["current"].min, times[ref].min
|
|
31
|
+
pct = (cur - old) / old * 100
|
|
32
|
+
step format("Fastest: current %.2f s, %s %.2f s (%+.0f%%)", cur, ref, old, pct)
|
|
33
|
+
step format("Median: current %.2f s, %s %.2f s", PerfStartup.median(times["current"]), ref, PerfStartup.median(times[ref]))
|
|
34
|
+
fail!(format("Startup is %.2f s slower than at %s", cur - old, ref), 1) if PerfStartup.slower?(cur, old)
|