Skip to content

Instantly share code, notes, and snippets.

pulkit110 / mock_websocket_server.ex
Last active Aug 17, 2021
Supplementary Code for Testing WebSocket Clients in Elixir with a Mock Server
View mock_websocket_server.ex
defmodule Commerce.Orders.MockWebsocketServer do
use Plug.Router
match _ do
send_resp(conn, 200, "Hello from plug")
View method_profiler.rb
require 'benchmark/ips'
require 'redis'
class MethodProfiler
def self.patch(klass, methods, name)
patches = do |method_name|
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]