Skip to content

Instantly share code, notes, and snippets.

@yuki24
Created June 3, 2017 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuki24/e0db97e887b8b6eb1932c41b4cea4a99 to your computer and use it in GitHub Desktop.
Save yuki24/e0db97e887b8b6eb1932c41b4cea4a99 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
require 'andpush'
require 'fcm'
server_key = ENV.fetch('FCM_TEST_SERVER_KEY')
DEVICE_TOKEN = ENV.fetch('FCM_TEST_REGISTRATION_TOKEN')
FCM_CLIENT = FCM.new(server_key)
PAYLOAD_FOR_FCM = { dry_run: true, notification: { title: "u", body: "y" } }
ANDPUSH_CLIENT = Andpush.build(server_key)
PAYLOAD_FOR_ANDPUSH = PAYLOAD_FOR_FCM.merge(to: DEVICE_TOKEN)
REGISTRATION_TOKENS = [DEVICE_TOKEN]
Benchmark.ips do |x|
x.report("andpush") { ANDPUSH_CLIENT.push(PAYLOAD_FOR_ANDPUSH).json }
x.report("fcm") { FCM_CLIENT.send(REGISTRATION_TOKENS, PAYLOAD_FOR_FCM) }
x.compare!
end
Warming up --------------------------------------
andpush 2.000 i/100ms
fcm 1.000 i/100ms
Calculating -------------------------------------
andpush 28.009 (± 7.1%) i/s - 140.000 in 5.019399s
fcm 7.452 (±13.4%) i/s - 37.000 in 5.023139s
Comparison:
andpush: 28.0 i/s
fcm: 7.5 i/s - 3.76x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment