-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homework 1 #133
Open
IgorArkhipov
wants to merge
7
commits into
hardcode-dev:master
Choose a base branch
from
IgorArkhipov:igor-arkhipov/performance-improvement-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28,254
−64
Open
Homework 1 #133
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a10280
Optimise performance step 1
IgorArkhipov 3782c94
Optimise performance step 2
IgorArkhipov 0208abf
Optimise performance step 3
IgorArkhipov 7dddaf9
Optimise performance step 4
IgorArkhipov 5bf5ed7
Optimise performance step 5
IgorArkhipov 7c06291
Optimise performance step 6
IgorArkhipov 8bf8178
Optimise performance step 7
IgorArkhipov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rspec-benchmark' | ||
require_relative 'task-1' | ||
|
||
RSpec.configure do |config| | ||
config.include RSpec::Benchmark::Matchers | ||
end | ||
|
||
describe 'Performance' do | ||
describe 'work' do | ||
# 100 lines under 0.32 milliseconds | ||
it 'should work under 0.32 milliseconds' do | ||
expect { work('data100.txt') }.to perform_under(0.32).ms.warmup(2).times.sample(10).times | ||
end | ||
|
||
# 1000 lines under 1.95 milliseconds | ||
it 'should work under 2 milliseconds' do | ||
expect { work('data1000.txt') }.to perform_under(1.95).ms.warmup(2).times.sample(10).times | ||
end | ||
|
||
# 10000 lines under 20 milliseconds | ||
it 'should work under 20 milliseconds' do | ||
expect { work('data10000.txt') }.to perform_under(20).ms.warmup(2).times.sample(10).times | ||
end | ||
|
||
let(:measurement_time_seconds) { 1 } | ||
let(:warmup_time_seconds) { 0.2 } | ||
it 'works faster than 3550 ips' do | ||
expect { work('data100.txt') }.to perform_at_least(3550).within(measurement_time_seconds).warmup(warmup_time_seconds).ips | ||
end | ||
|
||
it 'performs linear' do | ||
expect { |n, _i| work("data#{n}.txt") }.to perform_linear.in_range(1000, 8000).ratio(2) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'benchmark' | ||
require_relative 'task-1' | ||
|
||
# GC.disable | ||
puts 'Started' | ||
time = Benchmark.realtime do | ||
work('data_large.txt') | ||
end | ||
puts "Finished in #{time.round(2)}" | ||
|
||
# Iteration 0: measurement without any changes = 0.72 seconds | ||
# Iteration 1: measurement with changes for Array.select = 0.1 seconds | ||
# Iteration 2: measurement with changes for collect_stats_from_users = 0.1 seconds | ||
# Iteration 3: measurement with changes for all? = 0.07 seconds | ||
# Iteration 4: measurement with changes for split = 0.04 seconds | ||
# Iteration 5: measurement with changes for Date = 0.02 seconds | ||
# Iteration 6: measurement with changes for remaining map = 0.02 seconds | ||
# Iteration 7: measurement with changes for remaining array append = 0.02 seconds |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
user,0,Hazel,Margarete,19 | ||
session,0,0,Internet Explorer 50,81,2018-02-01 | ||
session,0,1,Safari 27,88,2017-10-28 | ||
session,0,2,Firefox 13,92,2016-11-02 | ||
session,0,3,Internet Explorer 40,37,2017-05-31 | ||
session,0,4,Internet Explorer 16,37,2017-11-21 | ||
session,0,5,Safari 19,22,2017-11-30 | ||
session,0,6,Chrome 31,74,2016-08-22 | ||
session,0,7,Firefox 46,76,2019-02-04 | ||
user,1,Wilfredo,Louetta,40 | ||
session,1,0,Firefox 38,68,2018-04-24 | ||
session,1,1,Internet Explorer 41,27,2016-09-06 | ||
session,1,2,Internet Explorer 1,74,2017-01-05 | ||
session,1,3,Firefox 47,28,2017-06-09 | ||
session,1,4,Internet Explorer 22,98,2016-11-03 | ||
user,2,Cecil,Rosalba,44 | ||
session,2,0,Safari 26,96,2018-08-20 | ||
session,2,1,Internet Explorer 10,3,2019-01-03 | ||
session,2,2,Internet Explorer 47,52,2016-07-31 | ||
session,2,3,Safari 34,37,2017-09-14 | ||
session,2,4,Internet Explorer 17,22,2016-07-10 | ||
session,2,5,Firefox 26,76,2017-02-06 | ||
session,2,6,Chrome 14,88,2017-02-19 | ||
session,2,7,Safari 31,113,2018-04-12 | ||
session,2,8,Chrome 20,72,2016-09-04 | ||
session,2,9,Safari 13,14,2017-07-26 | ||
user,3,Kieth,Noble,20 | ||
session,3,0,Safari 23,1,2018-02-19 | ||
session,3,1,Internet Explorer 24,92,2018-05-15 | ||
session,3,2,Chrome 6,91,2017-01-06 | ||
session,3,3,Internet Explorer 47,7,2016-09-01 | ||
session,3,4,Firefox 4,20,2017-03-22 | ||
session,3,5,Internet Explorer 23,17,2016-12-02 | ||
session,3,6,Internet Explorer 5,91,2017-12-29 | ||
session,3,7,Internet Explorer 23,2,2017-03-17 | ||
user,4,Corie,Erika,32 | ||
session,4,0,Chrome 11,49,2019-02-05 | ||
session,4,1,Safari 44,18,2017-09-01 | ||
session,4,2,Firefox 32,88,2017-06-01 | ||
session,4,3,Chrome 28,82,2018-03-18 | ||
session,4,4,Firefox 38,36,2018-06-11 | ||
session,4,5,Safari 14,11,2017-04-06 | ||
session,4,6,Safari 27,116,2017-05-30 | ||
session,4,7,Safari 24,36,2018-06-12 | ||
session,4,8,Firefox 3,28,2018-01-05 | ||
user,5,Lou,Lean,39 | ||
session,5,0,Internet Explorer 42,74,2017-08-20 | ||
session,5,1,Internet Explorer 1,80,2018-11-22 | ||
session,5,2,Chrome 18,105,2018-01-17 | ||
user,6,Deedra,Minta,44 | ||
session,6,0,Firefox 32,27,2017-07-07 | ||
session,6,1,Firefox 45,48,2017-07-22 | ||
session,6,2,Safari 33,55,2018-07-09 | ||
session,6,3,Safari 1,14,2016-11-08 | ||
session,6,4,Firefox 39,18,2017-02-06 | ||
session,6,5,Safari 12,52,2016-07-18 | ||
session,6,6,Firefox 18,84,2016-08-16 | ||
session,6,7,Chrome 2,114,2016-10-18 | ||
user,7,Loria,Vernetta,68 | ||
session,7,0,Safari 14,51,2019-01-25 | ||
session,7,1,Internet Explorer 29,88,2016-10-12 | ||
session,7,2,Firefox 32,55,2016-11-15 | ||
session,7,3,Safari 4,20,2016-11-19 | ||
session,7,4,Chrome 42,95,2018-02-10 | ||
session,7,5,Safari 36,88,2018-03-30 | ||
session,7,6,Safari 7,74,2017-05-27 | ||
session,7,7,Safari 18,67,2017-02-22 | ||
session,7,8,Chrome 24,26,2018-11-01 | ||
user,8,Abdul,Venessa,55 | ||
session,8,0,Internet Explorer 1,60,2018-12-02 | ||
session,8,1,Chrome 3,63,2016-10-02 | ||
session,8,2,Safari 41,99,2017-01-12 | ||
session,8,3,Firefox 13,69,2017-04-17 | ||
session,8,4,Safari 31,115,2018-04-08 | ||
session,8,5,Chrome 30,77,2019-01-28 | ||
session,8,6,Safari 43,56,2017-05-07 | ||
user,9,Brooks,Janae,6 | ||
session,9,0,Internet Explorer 36,11,2018-08-11 | ||
user,10,Rey,Coy,95 | ||
session,10,0,Internet Explorer 27,115,2017-08-05 | ||
session,10,1,Internet Explorer 21,119,2018-11-15 | ||
session,10,2,Internet Explorer 2,0,2016-06-10 | ||
session,10,3,Safari 13,44,2018-04-07 | ||
session,10,4,Firefox 37,26,2018-05-04 | ||
user,11,Cyrus,Danyel,41 | ||
session,11,0,Firefox 34,118,2016-10-14 | ||
session,11,1,Internet Explorer 34,45,2017-10-10 | ||
session,11,2,Internet Explorer 38,70,2017-07-10 | ||
user,12,Valentin,Emilio,21 | ||
session,12,0,Chrome 13,28,2018-04-23 | ||
session,12,1,Firefox 35,17,2018-11-29 | ||
session,12,2,Firefox 19,68,2018-05-03 | ||
session,12,3,Internet Explorer 14,2,2016-09-18 | ||
session,12,4,Firefox 15,97,2018-04-15 | ||
session,12,5,Safari 26,40,2016-06-13 | ||
user,13,Mitchell,Hobert,78 | ||
session,13,0,Internet Explorer 32,89,2019-02-07 | ||
session,13,1,Firefox 17,0,2017-11-05 | ||
session,13,2,Chrome 17,117,2018-12-12 | ||
session,13,3,Firefox 28,3,2016-12-01 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
раз оно линейно работает, можно довольно точно аппроксимировать
то есть если полный объём должен обработаться за 30 секунд, то 1/100 объёма за ~~ 300мс, соответственно можно бы один какой-то вместо 3ёх спеков спокойно оставить