mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
07d48bbe13
When generate Hash object, the heap area of st_table will be always allocated in internally and seems it take a time. To improve performance of creating Hash object, this patch will reduce count of allocating heap areas for st_table by reuse them. Performance of creating Hash literal -> 1.53 times faster. [Fix GH-1766] [ruby-core:84008] [Feature #14146] ### Environment * OS : macOS 10.13.1 * CPU : 1.4 GHz Intel Core i7 * Compiler : Apple LLVM version 9.0.0 (clang-900.0.39) ### Before $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 51.544k i/100ms Calculating ------------------------------------- Hash literal 869.132k (± 1.1%) i/s - 4.381M in 5.041574s ### After $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 63.068k i/100ms Calculating ------------------------------------- Hash literal 1.328M (± 2.3%) i/s - 6.685M in 5.037861s ### Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "Hash literal" do |loop| count = 0 while count < loop hash = {foo: 12, bar: 34, baz: 56} count += 1 end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
66 lines
1.2 KiB
C
66 lines
1.2 KiB
C
/**********************************************************************
|
|
|
|
inits.c -
|
|
|
|
$Author$
|
|
created at: Tue Dec 28 16:01:58 JST 1993
|
|
|
|
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
|
|
|
**********************************************************************/
|
|
|
|
#include "internal.h"
|
|
|
|
#define CALL(n) {void Init_##n(void); Init_##n();}
|
|
|
|
void
|
|
rb_call_inits(void)
|
|
{
|
|
CALL(st);
|
|
CALL(Method);
|
|
CALL(RandomSeedCore);
|
|
CALL(sym);
|
|
CALL(var_tables);
|
|
CALL(Object);
|
|
CALL(top_self);
|
|
CALL(Encoding);
|
|
CALL(Comparable);
|
|
CALL(Enumerable);
|
|
CALL(String);
|
|
CALL(Exception);
|
|
CALL(eval);
|
|
CALL(safe);
|
|
CALL(jump);
|
|
CALL(Numeric);
|
|
CALL(Bignum);
|
|
CALL(syserr);
|
|
CALL(Array);
|
|
CALL(Hash);
|
|
CALL(Struct);
|
|
CALL(Regexp);
|
|
CALL(pack);
|
|
CALL(transcode);
|
|
CALL(marshal);
|
|
CALL(Range);
|
|
CALL(IO);
|
|
CALL(Dir);
|
|
CALL(Time);
|
|
CALL(Random);
|
|
CALL(signal);
|
|
CALL(load);
|
|
CALL(Proc);
|
|
CALL(Binding);
|
|
CALL(Math);
|
|
CALL(GC);
|
|
CALL(Enumerator);
|
|
CALL(VM);
|
|
CALL(ISeq);
|
|
CALL(Thread);
|
|
CALL(process);
|
|
CALL(Cont);
|
|
CALL(Rational);
|
|
CALL(Complex);
|
|
CALL(version);
|
|
CALL(vm_trace);
|
|
}
|
|
#undef CALL
|