ivoanjo / gvl-tracing

Get a timeline view of Global VM Lock usage in your Ruby app
MIT License
114 stars 7 forks source link

Add support for passing a block to `start` method #14

Closed GustavoCaso closed 1 year ago

GustavoCaso commented 1 year ago

Add a new module function execute(filename) into GvlTracing wrapping call of start and stop methods.

This is one of the tasks from https://github.com/ivoanjo/gvl-tracing/issues/13

GustavoCaso commented 1 year ago

If we do not like the execute method we could rename the C methods to _start and _stop and add simply wrapper in Ruby land.

module GvlTracing
  class << self

    private :_start
    private :_stop

    def start(filename)
      _start(filename)

      if block_given?
        yield
        _stop
      end
    end

    def stop
      _stop
    end
  end
end
ivoanjo commented 1 year ago

Looks good! In #12 indeed we already are wrapping start/stop with Ruby versions as you suggested -- do you mind rebasing on top of master and adding the block_given? to start directly as you suggested?

GustavoCaso commented 1 year ago

@ivoanjo Done 🎉

ivoanjo commented 1 year ago

Thanks @GustavoCaso for the contribution! I've (finally, lol, thanks for the patience!) released it as v1.3.0 :)