gitlab-org--gitlab-foss/spec/lib/gitlab
Yorick Peterse d7b4f36a3c
Use clock_gettime for all performance timestamps
Process.clock_gettime allows getting the real time in nanoseconds as
well as allowing one to get a monotonic timestamp. This offers greater
accuracy without the overhead of having to allocate a Time instance. In
general using Time.now/Time.new is about 2x slower than using
Process.clock_gettime(). For example:

    require 'benchmark/ips'

    Benchmark.ips do |bench|
      bench.report 'Time.now' do
        Time.now.to_f
      end

      bench.report 'clock_gettime' do
        Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
      end

      bench.compare!
    end

Running this benchmark gives:

    Calculating -------------------------------------
                Time.now   108.052k i/100ms
           clock_gettime   125.984k i/100ms
    -------------------------------------------------
                Time.now      2.343M (± 7.1%) i/s -     11.670M
           clock_gettime      4.979M (± 0.8%) i/s -     24.945M

    Comparison:
           clock_gettime:  4979393.8 i/s
                Time.now:  2342986.8 i/s - 2.13x slower

Another benefit of using Process.clock_gettime() is that we can simplify
the code a bit since it can give timestamps in nanoseconds out of the
box.
2016-06-28 17:51:25 +02:00
..
backend Test Grack::Auth via a request spec 2016-03-23 14:09:52 +01:00
badge Fix tests failures 2016-06-07 10:25:57 +02:00
bitbucket_import Make Omniauth providers specs to not modify global configuration 2016-06-08 16:50:05 +02:00
ci Extract CI entry config hash validation to validator 2016-06-17 15:02:39 +02:00
database Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
diff Show a notice for diffs that are too large 2016-03-18 12:30:46 +01:00
email Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
fogbugz_import updated spec 2016-03-31 09:22:28 +02:00
gfm Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
github_import Merge branch 'gh-disable-webhooks' 2016-06-07 13:06:43 +02:00
gitlab_import Make Omniauth providers specs to not modify global configuration 2016-06-08 16:50:05 +02:00
gitorious_import Tag lib specs 2015-12-09 11:55:42 +01:00
google_code_import refactored code based on feedback plus fixed a couple of other issues 2016-03-28 16:35:03 +02:00
import_export fixed pipeline notes issue 2016-06-23 12:29:11 +02:00
ldap Unblocks user when active_directory is disabled and it can be found 2016-04-05 16:34:31 -03:00
lfs Add test coverage to LFS fetching 2016-06-21 11:26:44 +02:00
metrics Use clock_gettime for all performance timestamps 2016-06-28 17:51:25 +02:00
middleware Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
o_auth Added default setting for `external_providers` 2016-04-11 10:16:42 -05:00
saml Fix subsequent SAML sign ins 2016-06-22 16:10:55 -05:00
sanitizers Improved SVG sanitizer specs to include smoke tests for clean. 2016-06-12 21:05:58 -04:00
sherlock Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
sql Tag lib specs 2015-12-09 11:55:42 +01:00
template Refactor Gitlab::Gitignores 2016-06-20 14:48:28 -05:00
akismet_helper_spec.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
asciidoc_spec.rb Fix relative links in other markup formats 2016-02-12 17:20:59 +01:00
auth_spec.rb Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
award_emoji_spec.rb Merge branch 'master' into awardables 2016-05-30 18:54:08 +02:00
blame_spec.rb Move blame group logic to dedicated class 2016-01-28 14:49:21 +01:00
build_data_builder_spec.rb Suppress e-mails on failed builds if allow_failure is set 2016-01-07 10:45:39 -08:00
closing_issue_extractor_spec.rb Remove dumb debug statement and add many tests. 2016-04-07 08:47:29 -04:00
color_schemes_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
database_spec.rb Improve Issuable.order_labels_priority 2016-06-06 11:59:49 -05:00
exclusive_lease_spec.rb Improve test descriptions 2016-03-10 12:55:06 +01:00
git_access_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
git_access_wiki_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
highlight_spec.rb support cgi style options, such as erb?parent=json 2016-06-27 14:17:49 -07:00
incoming_email_spec.rb Improve and finish the fallback to the In-Reply-To and References header for the reply-by-email feature 2016-03-25 13:05:15 +01:00
key_fingerprint_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
lazy_spec.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
markup_helper_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
metrics_spec.rb Fix setting of "action" for Grape transactions 2016-04-20 22:42:52 +02:00
note_data_builder_spec.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
popen_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
project_search_results_spec.rb Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
push_data_builder_spec.rb Using single builder for push and tag events 2016-04-19 11:00:30 +02:00
reference_extractor_spec.rb Remove JiraIssue model and replace references with ExternalIssue 2016-06-16 01:25:18 +03:00
regex_spec.rb Allow "@" in file names and path 2016-02-01 16:20:49 +01:00
search_results_spec.rb Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
snippet_search_results_spec.rb Refactor Gitlab::SnippetSearchResults 2016-03-11 15:25:22 -05:00
themes_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
upgrader_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
uploads_transfer_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
url_builder_spec.rb Revert "Merge branch 'wiki-fix' into 'master' " 2016-05-10 10:57:48 +02:00
url_sanitizer_spec.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
version_info_spec.rb Tag lib specs 2015-12-09 11:55:42 +01:00
workhorse_spec.rb Add workhorse controller and API helpers 2016-06-06 13:16:30 +02:00