Files
ubicloud/spec/clec
Daniel Farina 034733df15 Introduce autoloading of a test helper
Clec is a portmanteau of "Clover Spec," unlikely to collide with
anything, and short, like `Clog`.

I was optimizing some tests using encryption keys, moving from the
faster generation of EC keys to not generating new keys at all, and
instead using saved fixtures.

Because that code requires OpenSSL, and I don't want to always require
it in `spec_helper.rb`, I am establishing a pattern here for
autoloading instead.

You can put this code in a test to benchmark:

    n = 100000

    Benchmark.bm do |x|
      x.report("Reference") { n.times { Clec::Cert.ec_key } }
      x.report("Generate") { n.times { OpenSSL::PKey::EC.generate("prime256v1") } }
    end

    user     system      total      real
    Generate  3.861523   0.089509   3.951032 (  3.951055)
    Reference 0.052119   0.000000   0.052119 (  0.052114)
2024-10-29 07:40:12 -07:00
..
2024-10-29 07:40:12 -07:00