Skip to content

Commit 7cc1158

Browse files
Autoload OpenSSL (#3188)
* Profile and benchmark with autoload Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com> * Remove scripts Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com> * Autoload OpenSSL Profiling laoding faker showed that by autoloading OpenSSL, we could improve Faker's loading time by about 17%. A lot of the time is spent on set_default_paths. Given that OpenSSL is only used in a very limited way and only by 3 generators, this would speed up the library for most users. Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com> --------- Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
1 parent 9cadf41 commit 7cc1158

4 files changed

Lines changed: 2 additions & 4 deletions

File tree

lib/faker.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
require 'psych'
66
require 'i18n'
77

8+
autoload(:OpenSSL, 'openssl')
9+
810
Dir.glob(File.join(mydir, 'helpers', '*.rb')).each { |file| require file }
911

1012
I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]

lib/faker/blockchain/bitcoin.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'openssl'
43
require 'securerandom'
54

65
module Faker

lib/faker/blockchain/tezos.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'openssl'
43
require 'securerandom'
54

65
module Faker

lib/faker/default/crypto.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'openssl'
4-
53
module Faker
64
class Crypto < Base
75
class << self

0 commit comments

Comments
 (0)