WIP all the things

This commit is contained in:
Jorge Morante 2022-05-18 15:11:54 +02:00
parent 1df76c7305
commit 4d45983f71
13 changed files with 65 additions and 28 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ node_modules/
vendor/bundle
.cache
.byebug_history
shared

View File

@ -1,14 +1,14 @@
ARG RUBY_VERSION=2.6.10
FROM ruby:$RUBY_VERSION
ARG TMUX_VERSION=2.9
ARG TMUX_VERSION=3.2
COPY . /app
WORKDIR /app
COPY spec/use-tmux.sh /tmp/use-tmux.sh
COPY spec/install-tmux-versions.sh /tmp/install-tmux-versions.sh
# Run CI scripts
RUN CI_TMUX_VERSION=$TMUX_VERSION /app/spec/install-tmux-versions.sh
RUN /app/spec/use-tmux.sh $TMUX_VERSION
RUN CI_TMUX_VERSION=$TMUX_VERSION /tmp/install-tmux-versions.sh
RUN /tmp/use-tmux.sh $TMUX_VERSION
# Install linux-perf
RUN apt-get update && apt-get install -y linux-perf-5.10
@ -16,10 +16,24 @@ RUN apt-get update && apt-get install -y linux-perf-5.10
# Mock action stub globally
RUN ln -s /app/spec/action-stub.sh /usr/local/bin/action-stub
# Install hyperfine
RUN wget https://github.com/sharkdp/hyperfine/releases/download/v1.13.0/hyperfine_1.13.0_amd64.deb
RUN dpkg -i hyperfine_1.13.0_amd64.deb
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock
WORKDIR /app
# Install ruby stuff
RUN gem install bundler
RUN bundle install
# Install rbspy
RUN wget https://github.com/rbspy/rbspy/releases/download/v0.12.1/rbspy-x86_64-musl.tar.gz -O /tmp/rbspy.tar.gz
RUN cd /tmp && tar pfx /tmp/rbspy.tar.gz
RUN mv /tmp/rbspy-x86_64-musl /usr/local/bin/rbspy
RUN chmod a+x /usr/local/bin/rbspy
# Expose byebug remote debugging port
EXPOSE 1048

13
benchmark.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
tmux -f spec/conf/benchmark.conf new-session -d
tmux resize-window -t '@0' -x 300 -y 100
tmux send-keys 'COLUMNS=$COLUMNS LINES=$LINES ruby spec/fill_screen.rb'
tmux send-keys Enter
#tmux send-keys 'rbspy record -f /app/shared/report.svg -- /usr/local/bin/ruby --disable-gems bin/fingers start fingers-mode $TMUX_PANE self'
#tmux send-keys Enter
tmux send-keys 'hyperfine "/usr/local/bin/ruby --disable-gems bin/fingers trace_start"'
#tmux send-keys 'hyperfine "/usr/local/bin/ruby --disable-gems bin/fingers start fingers-mode $TMUX_PANE self"'
tmux send-keys Enter

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: "3.9"
services:
shell:
cap_add:
- SYS_PTRACE
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/app

View File

@ -98,7 +98,7 @@ class Fingers::Commands::LoadConfig < Fingers::Commands::Base
ruby_bin = "#{RbConfig.ruby} --disable-gems"
`tmux bind-key #{Fingers.config.key} run-shell -b "#{ruby_bin} #{cli} start '#{input_mode}' '\#{pane_id}' self >>#{Fingers::Dirs::LOG_PATH} 2>&1"`
`tmux bind-key F run-shell -b "#{ruby_bin} #{cli} start '#{input_mode}' '\#{pane_id}' other >>#{Fingers::Dirs::LOG_PATH} 2>&1"`
`tmux bind-key O run-shell -b "#{ruby_bin} #{cli} start '#{input_mode}' '\#{pane_id}' other >>#{Fingers::Dirs::LOG_PATH} 2>&1"`
setup_fingers_mode_bindings if input_mode == 'fingers-mode'
end

View File

@ -1,11 +1,17 @@
class PanePrinter
def initialize(pane_tty)
@pane_tty = pane_tty
@buf = ''
@file = File.open(@pane_tty, 'w')
end
def print(msg)
@file.print(msg)
#@buf += msg
end
def flush
#@file.print(@buf)
end
end

View File

@ -1,6 +1,5 @@
class Fingers::Commands::TraceStart < Fingers::Commands::Base
def run
Fingers.benchmark_stamp('boot:start')
Fingers.benchmark_stamp('ready-for-input:start')
exit 0
end
end

View File

@ -25,6 +25,7 @@ class ::Fingers::Hinter
process_line(lines[-1], '')
STDOUT.flush
output.flush
build_lookup_table!
end

View File

@ -7,7 +7,7 @@ module Fingers
@logger = Logger.new(
Fingers::Dirs::LOG_PATH
)
@logger.level = Logger.const_get(ENV.fetch('FINGERS_LOG_LEVEL', 'DEBUG'))
@logger.level = Logger.const_get(ENV.fetch('FINGERS_LOG_LEVEL', 'INFO'))
@logger
end

View File

@ -1,3 +1,6 @@
# frozen_string_literal: true
# rubocop:disable Metrics/ClassLength
class Tmux
include Singleton
@ -211,3 +214,6 @@ class Tmux
socket
end
end
#Tmux = TmuxControl
# rubocop:enable Metrics/ClassLength

View File

@ -5,25 +5,12 @@ require 'benchmark'
describe 'performance', performance: true do
include_context 'tmuxomatic setup'
let(:config_name) { 'benchmark' }
let(:tmuxomatic_window_width) { 1000 }
let(:tmuxomatic_window_height) { 1000 }
let(:tmuxomatic_window_width) { 100 }
let(:tmuxomatic_window_height) { 100 }
it 'runs smooooooth' do
exec('COLUMNS=$COLUMNS LINES=$LINES ruby spec/fill_screen.rb')
pane_id = tmuxomatic.panes.first.pane_id
ruby = RbConfig.ruby
byebug
#puts "Measuring fingers execution"
#fingers_measurement = Benchmark.measure do
#`FINGERS_TMUX_SOCKET=tmuxomatic_inner #{ruby} -e "puts :hello"`
##`FINGERS_TMUX_SOCKET=tmuxomatic_inner #{ruby} --disable-gems bin/fingers start fingers-mode '#{pane_id}'`
#end
#puts fingers_measurement
#puts "measure: #{fingers_measurement.real * 1000.0} ms"
exec('COLUMNS=$COLUMNS LINES=$LINES ruby spec/fill_screen.rb')
exec(%(hyperfine --export-json /tmp/perf.json "#{ruby} --disable-gems bin/fingers start fingers-mode $TMUX_PANE self"))
end
end

View File

@ -1,3 +1,3 @@
set -g prefix C-a
set -g default-terminal 'screen-256color'
run 'tmux-fingers.tmux'
run '/app/tmux-fingers.tmux'

View File

@ -1,4 +1,4 @@
set -g prefix C-a
set -g @fingers-trace-perf '1'
set -g default-terminal 'screen-256color'
run 'tmux-fingers.tmux'
run '/app/tmux-fingers.tmux'