mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:41:12 +08:00
DEV: Apply syntax_tree formatting to script/*
This commit is contained in:
@ -1,37 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'benchmark/ips'
|
||||
require File.expand_path('../../../../config/environment', __FILE__)
|
||||
require "benchmark/ips"
|
||||
require File.expand_path("../../../../config/environment", __FILE__)
|
||||
|
||||
# Put pre conditions here
|
||||
# Used db but it's OK in the most cases
|
||||
|
||||
# build the cache
|
||||
SiteSetting.title = SecureRandom.hex
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == 'en' ? 'zh_CN' : 'en'
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == "en" ? "zh_CN" : "en"
|
||||
SiteSetting.refresh!
|
||||
|
||||
tests = [
|
||||
["current cache", lambda do
|
||||
SiteSetting.title
|
||||
SiteSetting.enable_discourse_connect
|
||||
end
|
||||
[
|
||||
"current cache",
|
||||
lambda do
|
||||
SiteSetting.title
|
||||
SiteSetting.enable_discourse_connect
|
||||
end,
|
||||
],
|
||||
["change default locale with current cache refreshed", lambda do
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == 'en' ? 'zh_CN' : 'en'
|
||||
end
|
||||
],
|
||||
["change site setting", lambda do
|
||||
SiteSetting.title = SecureRandom.hex
|
||||
end
|
||||
[
|
||||
"change default locale with current cache refreshed",
|
||||
lambda { SiteSetting.default_locale = SiteSetting.default_locale == "en" ? "zh_CN" : "en" },
|
||||
],
|
||||
["change site setting", lambda { SiteSetting.title = SecureRandom.hex }],
|
||||
]
|
||||
|
||||
Benchmark.ips do |x|
|
||||
tests.each do |test, proc|
|
||||
x.report(test, proc)
|
||||
end
|
||||
end
|
||||
Benchmark.ips { |x| tests.each { |test, proc| x.report(test, proc) } }
|
||||
|
||||
# 2017-08-02 - Erick's Site Setting change
|
||||
|
||||
|
@ -1,34 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'ruby-prof'
|
||||
require "ruby-prof"
|
||||
|
||||
def profile(&blk)
|
||||
result = RubyProf.profile(&blk)
|
||||
printer = RubyProf::GraphHtmlPrinter.new(result)
|
||||
printer.print(STDOUT)
|
||||
end
|
||||
profile { '' } # loading profiler dependency
|
||||
profile { "" } # loading profiler dependency
|
||||
|
||||
require File.expand_path('../../../../config/environment', __FILE__)
|
||||
require File.expand_path("../../../../config/environment", __FILE__)
|
||||
|
||||
# warming up
|
||||
SiteSetting.title
|
||||
SiteSetting.enable_discourse_connect
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == 'en' ? 'zh_CN' : 'en'
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == "en" ? "zh_CN" : "en"
|
||||
SiteSetting.title = SecureRandom.hex
|
||||
|
||||
profile do
|
||||
SiteSetting.title
|
||||
end
|
||||
profile { SiteSetting.title }
|
||||
|
||||
profile do
|
||||
SiteSetting.enable_discourse_connect
|
||||
end
|
||||
profile { SiteSetting.enable_discourse_connect }
|
||||
|
||||
profile do
|
||||
SiteSetting.default_locale = SiteSetting.default_locale == 'en' ? 'zh_CN' : 'en'
|
||||
end
|
||||
profile { SiteSetting.default_locale = SiteSetting.default_locale == "en" ? "zh_CN" : "en" }
|
||||
|
||||
profile do
|
||||
SiteSetting.title = SecureRandom.hex
|
||||
end
|
||||
profile { SiteSetting.title = SecureRandom.hex }
|
||||
|
Reference in New Issue
Block a user