diff options
author | Eric Wong <e@80x24.org> | 2014-11-16 08:32:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-12-13 02:50:12 +0000 |
commit | 5b5cf896871efdb110ae831fd7fc34fb78ec2243 (patch) | |
tree | 697b8c2dffafd2822148af3fc95e3f1d6677c782 /test/unit | |
parent | 639cc06cb0350e1a934f151fcbdb72a1c681792c (diff) | |
download | unicorn-5b5cf896871efdb110ae831fd7fc34fb78ec2243.tar.gz |
This provides some extra type safety if combined with other C extensions, as well as allowing us to account for memory usage of the HTTP parser in ObjectSpace. This requires Ruby 1.9.3+ and has remained a stable API since then. This will become officially supported when Ruby 2.3.0 is released later this month. This API has only been documented in doc/extension.rdoc (formerly README.EXT) in the Ruby source tree since April 2015, r50318
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/test_http_parser.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb index 431ede5..c72f7f2 100644 --- a/test/unit/test_http_parser.rb +++ b/test/unit/test_http_parser.rb @@ -851,4 +851,18 @@ class HttpParserTest < Test::Unit::TestCase File.readable?(LINUX_PROC_PID_STATUS) && !defined?(RUBY_ENGINE) + def test_memsize + require 'objspace' + if ObjectSpace.respond_to?(:memsize_of) + n = ObjectSpace.memsize_of(Unicorn::HttpParser.new) + assert_kind_of Integer, n + # need to update this when 128-bit machines come out + # n.b. actual struct size on 64-bit is 56 bytes + 40 bytes for RVALUE + # Ruby <= 2.2 objspace did not count the 40-byte RVALUE, 2.3 does. + assert_operator n, :<=, 96 + assert_operator n, :>, 0 + end + rescue LoadError + # not all Ruby implementations have objspace + end end |