Last active
February 9, 2018 20:28
-
-
Save robacarp/d20ed807003d96e76a8538fab17e8af5 to your computer and use it in GitHub Desktop.
Undoctored logs for Rails vs Amber speed comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started GET "/bookmarks" for 127.0.0.1 at 2018-01-11 10:48:37 -0700 | |
Processing by BookmarksController#index as HTML | |
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]] | |
Rendering bookmarks/index.html.haml within layouts/application | |
Rendered bookmarks/_navbar.html.haml (3.7ms) | |
Bookmark Exists (0.4ms) SELECT 1 AS one FROM "bookmarks" LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 0]] | |
Bookmark Load (0.4ms) SELECT "bookmarks".* FROM "bookmarks" ORDER BY "bookmarks"."created_at" ASC LIMIT $1 OFFSET $2 [["LIMIT", 25], ["OFFSET", 0]] | |
Webpage Load (0.4ms) SELECT "webpages".* FROM "webpages" WHERE "webpages"."id" IN ($1, $2, $3, $4, $5, $6) [["id", 1], ["id", 4], ["id", 5], ["id", 6], ["id", 7], ["id", 8]] | |
Tag Load (6.6ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 5]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (49.5ms) | |
Tag Load (0.4ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 7]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (2.4ms) | |
Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 8]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (1.6ms) | |
Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 9]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (1.7ms) | |
Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 10]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (1.4ms) | |
Tag Load (0.2ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 11]] | |
Rendered bookmarks/_bookmark_list_item.html.haml (1.6ms) | |
Rendered bookmarks/_bookmark_list.html.haml (115.7ms) | |
Rendered bookmarks/index.html.haml within layouts/application (126.1ms) | |
Rendered layouts/_head.html.haml (16.8ms) | |
Rendered layouts/_navbar.html.haml (6.8ms) | |
Rendered layouts/_body.html.haml (10.0ms) | |
Rendered layouts/_footer.html.haml (5.9ms) | |
Completed 200 OK in 251ms (Views: 217.9ms | ActiveRecord: 15.9ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
04:55:07 (INFO) Server | SELECT users.id, users.name, users.email, users.crypted_password, users.created_at, users.updated_at FROM users WHERE id=$1 LIMIT 1: 2 | |
04:55:07 (INFO) Server | SELECT domains.id, domains.name, domains.user_id, domains.created_at, domains.updated_at FROM domains WHERE id=$1 LIMIT 1: 30 | |
04:55:07 (INFO) Server | SELECT routes.id, routes.path, routes.expected_content, routes.expected_code, routes.use_ssl, routes.domain_id, routes.created_at, routes.updated_at FROM routes WHERE routes.domain_id = $1: 30 | |
04:55:07 (INFO) Server | SELECT routes.id, routes.path, routes.expected_content, routes.expected_code, routes.use_ssl, routes.domain_id, routes.created_at, routes.updated_at FROM routes WHERE routes.domain_id = $1: 30 | |
04:55:07 (INFO) Server | SELECT routes.id, routes.path, routes.expected_content, routes.expected_code, routes.use_ssl, routes.domain_id, routes.created_at, routes.updated_at FROM routes WHERE routes.domain_id = $1: 30 | |
04:55:07 (INFO) Server | SELECT domains.id, domains.name, domains.user_id, domains.created_at, domains.updated_at FROM domains WHERE id=$1 LIMIT 1: 30 | |
04:55:07 (INFO) Server | SELECT get_results.id, get_results.check_id, get_results.is_up, get_results.response_time, get_results.response_code, get_results.found_expected_content, get_results.route_id, get_results.created_at, get_results.updated_at FROM get_results WHERE get_results.route_id = $1 | |
ORDER BY created_at DESC | |
LIMIT 1: [49_i64] | |
04:55:07 (INFO) Server | SELECT ip_addresses.id, ip_addresses.address, ip_addresses.version, ip_addresses.domain_id, ip_addresses.created_at, ip_addresses.updated_at FROM ip_addresses WHERE domain_id = $1: 30 | |
04:55:07 (INFO) Server | SELECT ip_addresses.id, ip_addresses.address, ip_addresses.version, ip_addresses.domain_id, ip_addresses.created_at, ip_addresses.updated_at FROM ip_addresses WHERE domain_id = $1: 30 | |
04:55:07 (INFO) Server | SELECT ping_results.id, ping_results.ip_address_id, ping_results.is_up, ping_results.response_time, ping_results.created_at, ping_results.updated_at FROM ping_results WHERE ping_results.ip_address_id = $1 | |
ORDER BY created_at DESC | |
LIMIT 1: [16_i64] | |
04:55:07 Request | Started 2018-01-12 16:55:07 -07:00 | |
04:55:07 Request | Status: 200 Method: GET Pipeline: web Format: html | |
04:55:07 Request | Requested Url: /domain/30 | |
04:55:07 Request | Time Elapsed: 14.36ms | |
04:55:07 Headers | Host: ["0.0.0.0:3000"] | |
04:55:07 Headers | User-Agent: ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0"] | |
04:55:07 Headers | Accept: ["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"] | |
04:55:07 Headers | Accept-Language: ["en-US,en;q=0.5"] | |
04:55:07 Headers | Accept-Encoding: ["gzip, deflate"] | |
04:55:07 Headers | Referer: ["http://0.0.0.0:3000/my/domains"] | |
04:55:07 Headers | Cookie: ["amber.session=eyJfZmxhc2giOiJ7fSIsImNzcmYudG9rZW4iOiJzNFFWaUtIcHN3SkZKQ3FaNkc4VkxXalI5aFVFNnpaSUY3Ti1hb1ZmM1dzIiwidXNlcl9pZCI6IjIifQ%3D%3D--ixwYWABMSXHWAa5J54S7thh0Dkg%3D"] | |
04:55:07 Headers | Connection: ["keep-alive"] | |
04:55:07 Headers | Upgrade-Insecure-Requests: ["1"] | |
04:55:07 Headers | DNT: ["1"] | |
04:55:07 Cookies | amber.session: #<HTTP::Cookie:0x107856a80> | |
04:55:07 Params | id: 30 | |
04:55:07 Session | _flash: {} | |
04:55:07 Session | csrf.token: s4QViKHpswJFJCqZ6G8VLWjR9hUE6zZIF7N-aoVf3Ws | |
04:55:07 Session | user_id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DomainController < ApplicationController | |
authorize_with DomainPolicy, Domain | |
require_logged_in | |
def show | |
if domain = Domain.find params["id"] | |
authorize domain | |
render "show.slang" | |
else | |
flash["warning"] = "Domain doesnt exist." | |
redirect_to_domains | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Domain < Granite::ORM::Base | |
adapter pg | |
field name : String | |
timestamps | |
belongs_to :user | |
has_many :routes | |
# has_many :ip_addresses, class: IpAddress | |
def ip_addresses : Array(IpAddress) | |
IpAddress.all("WHERE domain_id = ?", id) | |
end | |
# has_many :ping_results, through: :ip_addresses | |
def ping_results : Array(PingResult) | |
query = <<-SQL | |
JOIN ip_addresses ON ip_addresses.id = ping_result.ip_address_id | |
WHERE | |
ip_addresses.domain_id = ? | |
SQL | |
PingResult.all query | |
end | |
def up? | |
true | |
end | |
def checked? | |
ping_results.any? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.row | |
.col-md-6 | |
h3 = domain.name | |
.col-md-6.text-right | |
a href="/domain/#{domain.id}/delete" stop monitoring this domain | |
| Checking #{domain.routes.size} routes: | |
- if domain.routes.any? | |
table.table.table-dark | |
tr | |
th scope="col" Path | |
th scope="col" Status | |
th scope="col" Last Checked | |
th scope="col" Response Time | |
- domain.routes.each do |route| | |
tr | |
th scope="row" | |
a href="/route/#{route.id}" = route.full_path | |
td | |
- if route.last_result.is_up? | |
.green [up] | |
- else | |
- if route.last_result.checked? | |
.red [down] | |
- else | |
.pink [unchecked] | |
td = route.last_result.relative_time_since | |
td | |
= route.last_result.response_time | |
| ms | |
a href="/domain/#{domain.id}/routes/new" Create a route | |
h4 Most recent pings: | |
- if domain.ip_addresses.any? | |
table.table.table-dark | |
tr | |
th scope="col" Address | |
th scope="col" Status | |
th scope="col" Last Ping | |
th scope="col" Latency | |
- domain.ip_addresses.each do |address| | |
tr | |
th scope="row" == address.address | |
td | |
- if address.last_result.is_up? | |
.green [up] | |
- else | |
- if address.last_result.checked? | |
.red [down] | |
- else | |
.pink [unchecked] | |
td == address.last_result.relative_time_since | |
td | |
== address.last_result.response_time | |
| ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BookmarksController < ApplicationController | |
require_login! | |
def index | |
@bookmarks = current_user.bookmarks.page params[:page] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bookmark < ApplicationRecord | |
belongs_to :user | |
belongs_to :webpage | |
has_and_belongs_to_many :tags | |
default_scope { includes(:webpage) } | |
delegate :uri_string, to: :webpage | |
delegate :uri, to: :webpage | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for :page_title do | |
Bookmarks | |
= render "navbar" | |
- content_for :body do | |
.ui.row | |
%h1 Your Bookmarks | |
.ui.row | |
.ui.search | |
.ui.icon.input | |
= form_tag search_bookmarks_path, method: :get do | |
= search_field_tag "q", params[:q], class: "ui prompt", placeholder: "Search ...", aria: { label: "search" } | |
%i.search.icon | |
.ui.row | |
.ui.divider | |
= render partial: "bookmark_list", locals: { bookmarks: @bookmarks } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# bookmark_list partial | |
- if bookmarks.any? | |
.ui.row | |
.ui.very.relaxed.divided.list | |
- bookmarks.each do |bookmark| | |
= render partial: "bookmark_list_item", locals: { bookmark: bookmark } | |
.ui.row.centered | |
= paginate bookmarks | |
- else | |
.ui.row.centered | |
%i.massive.warning.sign.icon | |
.ui.row.centered | |
%h1.huge.header Uh oh, nothing found! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# bookmark_list_item | |
.item | |
%i.bookmark.icon | |
.content | |
.item | |
= link_to bookmark_cache_path(bookmark), data: { turbolinks: false }, class: "archive-link" do | |
%i.archive.icon | |
= link_to bookmark.title, bookmark_path(bookmark) | |
= link_to bookmark.uri_string | |
.description | |
= bookmark.description | |
- if bookmark.description.present? | |
%br | |
.ui.small.tag.labels | |
- bookmark.tags.each do |tag| | |
= link_to tag_bookmarks_path(tag.label) do | |
.ui.label{ class: [tag.color] }= tag.label | |
= bookmark.updated_at.to_date.to_s(:long) | |
| | |
= link_to "edit", edit_bookmark_path(bookmark) | |
| | |
= link_to "delete", bookmark_path(bookmark), method: :delete, data: { confirm: "really delete #{ bookmark.title }? REALLY?!" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment