Skip to content

Instantly share code, notes, and snippets.

require 'benchmark/ips'
require 'redis'
class MethodProfiler
def self.patch(klass, methods, name)
patches = methods.map do |method_name|
<<~RUBY
unless defined?(#{method_name}__mp_unpatched)
alias_method :#{method_name}__mp_unpatched, :#{method_name}
def #{method_name}(*args, &blk)
unless prof = Thread.current[:_method_profiler]
@pulkit110
pulkit110 / mock_websocket_server.ex
Last active February 24, 2023 04:21
Supplementary Code for Testing WebSocket Clients in Elixir with a Mock Server
defmodule Commerce.Orders.MockWebsocketServer do
use Plug.Router
plug(:match)
plug(:dispatch)
match _ do
send_resp(conn, 200, "Hello from plug")
end