liquid-c 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -1
- data/Gemfile +8 -0
- data/README.md +19 -0
- data/Rakefile +23 -4
- data/ext/liquid_c/extconf.rb +4 -0
- data/ext/liquid_c/liquid.c +3 -0
- data/ext/liquid_c/liquid.h +3 -3
- data/ext/liquid_c/tokenizer.c +5 -5
- data/ext/liquid_c/tokenizer.h +1 -4
- data/lib/liquid/c.rb +9 -10
- data/lib/liquid/c/version.rb +1 -1
- data/performance.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f1e4b7a91ef500fc48563ecdff875658c045b0e
|
4
|
+
data.tar.gz: 460cbca81b9ff70a9c20e4051cdc62a26a1e2c7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ecf742609e18e26a982897562f3ff0ef0c06e77045d12b98ad36fda3081e4350faffb9bae860ce1ecc060d8c6138b7fd482c323d763538dc38b13bc5738d1f8
|
7
|
+
data.tar.gz: 817638febdcb9a54399ab8aec528091b1c24f66510816e455f09b85bce9b2c1f7a5e559a89ab5611327b1d0f780c9d62fcb36ad0b231eaba35554f551bcdc80e
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,25 @@ then just use the documented API for the liquid Gem.
|
|
27
27
|
of an array of strings, which only implements the shift method
|
28
28
|
to get the next token.
|
29
29
|
|
30
|
+
## Performance
|
31
|
+
|
32
|
+
To compare Liquid-C's performance with plain Liquid run
|
33
|
+
|
34
|
+
bundle exec rake compare:run
|
35
|
+
|
36
|
+
The latest benchmark results are shown below:
|
37
|
+
|
38
|
+
user system total real
|
39
|
+
Liquid: 0.000000 0.000000 246.950000 (247.499526)
|
40
|
+
Liquid-C: 0.000000 0.010000 224.270000 (224.794395)
|
41
|
+
Ratio: 90.82619215891624%
|
42
|
+
|
43
|
+
## Developing
|
44
|
+
|
45
|
+
bundle install
|
46
|
+
# run tests
|
47
|
+
bundle exec rake
|
48
|
+
|
30
49
|
## Contributing
|
31
50
|
|
32
51
|
1. Fork it ( http://github.com/Shopify/liquid-c/fork )
|
data/Rakefile
CHANGED
@@ -2,7 +2,9 @@ require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/extensiontask'
|
5
|
+
require 'benchmark'
|
5
6
|
|
7
|
+
ENV['DEBUG'] = 'true'
|
6
8
|
Rake::ExtensionTask.new("liquid_c")
|
7
9
|
|
8
10
|
task :default => :test
|
@@ -34,12 +36,12 @@ end
|
|
34
36
|
namespace :benchmark do
|
35
37
|
desc "Run the liquid benchmark with lax parsing"
|
36
38
|
task :run do
|
37
|
-
ruby "./performance.rb benchmark lax"
|
39
|
+
ruby "./performance.rb c benchmark lax"
|
38
40
|
end
|
39
41
|
|
40
42
|
desc "Run the liquid benchmark with strict parsing"
|
41
43
|
task :strict do
|
42
|
-
ruby "./performance.rb benchmark strict"
|
44
|
+
ruby "./performance.rb c benchmark strict"
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -47,11 +49,28 @@ end
|
|
47
49
|
namespace :profile do
|
48
50
|
desc "Run the liquid profile/performance coverage"
|
49
51
|
task :run do
|
50
|
-
ruby "./performance.rb profile lax"
|
52
|
+
ruby "./performance.rb c profile lax"
|
51
53
|
end
|
52
54
|
|
53
55
|
desc "Run the liquid profile/performance coverage with strict parsing"
|
54
56
|
task :strict do
|
55
|
-
ruby "./performance.rb profile strict"
|
57
|
+
ruby "./performance.rb c profile strict"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
namespace :compare do
|
62
|
+
include Benchmark
|
63
|
+
desc "Compare Liquid to Liquid + Liquid-C"
|
64
|
+
task :run do
|
65
|
+
bare = Benchmark.measure do
|
66
|
+
ruby "./performance.rb bare profile lax"
|
67
|
+
end
|
68
|
+
liquid_c = Benchmark.measure do
|
69
|
+
ruby "./performance.rb c profile lax"
|
70
|
+
end
|
71
|
+
Benchmark.benchmark(CAPTION, 10, FORMAT, "Liquid:", "Liquid-C:") do |x|
|
72
|
+
[bare, liquid_c]
|
73
|
+
end
|
74
|
+
puts "Ratio: #{liquid_c.real / bare.real * 100}%"
|
56
75
|
end
|
57
76
|
end
|
data/ext/liquid_c/extconf.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
$CFLAGS << ' -Wall -Werror'
|
3
|
+
compiler = RbConfig::MAKEFILE_CONFIG['CC']
|
4
|
+
if ENV['DEBUG'] == 'true' && compiler =~ /gcc|g\+\+/
|
5
|
+
$CFLAGS << ' -fbounds-check'
|
6
|
+
end
|
3
7
|
$warnflags.gsub!(/-Wdeclaration-after-statement/, "")
|
4
8
|
create_makefile("liquid_c")
|
data/ext/liquid_c/liquid.c
CHANGED
data/ext/liquid_c/liquid.h
CHANGED
data/ext/liquid_c/tokenizer.c
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#include "liquid.h"
|
2
|
+
#include "tokenizer.h"
|
2
3
|
|
3
4
|
VALUE cLiquidTokenizer;
|
4
|
-
rb_encoding *utf8_encoding;
|
5
5
|
|
6
|
-
static void tokenizer_mark(void *ptr)
|
6
|
+
static void tokenizer_mark(void *ptr)
|
7
|
+
{
|
7
8
|
tokenizer_t *tokenizer = ptr;
|
8
9
|
rb_gc_mark(tokenizer->source);
|
9
10
|
}
|
@@ -21,8 +22,8 @@ static size_t tokenizer_memsize(const void *ptr)
|
|
21
22
|
|
22
23
|
const rb_data_type_t tokenizer_data_type = {
|
23
24
|
"liquid_tokenizer",
|
24
|
-
{tokenizer_mark, tokenizer_free, tokenizer_memsize,},
|
25
|
-
#
|
25
|
+
{ tokenizer_mark, tokenizer_free, tokenizer_memsize, },
|
26
|
+
#if defined(RUBY_TYPED_FREE_IMMEDIATELY)
|
26
27
|
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
27
28
|
#endif
|
28
29
|
};
|
@@ -134,5 +135,4 @@ void init_liquid_tokenizer()
|
|
134
135
|
rb_define_alloc_func(cLiquidTokenizer, tokenizer_allocate);
|
135
136
|
rb_define_method(cLiquidTokenizer, "initialize", tokenizer_initialize_method, 1);
|
136
137
|
rb_define_method(cLiquidTokenizer, "shift", tokenizer_shift_method, 0);
|
137
|
-
utf8_encoding = rb_utf8_encoding();
|
138
138
|
}
|
data/ext/liquid_c/tokenizer.h
CHANGED
data/lib/liquid/c.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'liquid/c/version'
|
2
2
|
require 'liquid'
|
3
|
-
|
4
|
-
# workaround bundler issue #2947 which could cause an old extension to be used
|
5
|
-
require 'rbconfig'
|
6
|
-
ext_path = File.expand_path("../../liquid_c.#{RbConfig::CONFIG['DLEXT']}", __FILE__)
|
7
|
-
if File.exists?(ext_path)
|
8
|
-
require ext_path
|
9
|
-
else
|
10
|
-
require 'liquid_c'
|
11
|
-
end
|
3
|
+
require 'liquid_c'
|
12
4
|
|
13
5
|
Liquid::Template.class_eval do
|
14
6
|
private
|
15
7
|
|
8
|
+
alias_method :ruby_tokenize, :tokenize
|
9
|
+
|
16
10
|
def tokenize(source)
|
17
|
-
|
11
|
+
if @line_numbers
|
12
|
+
ruby_tokenize(source)
|
13
|
+
else
|
14
|
+
Liquid::Tokenizer.new(source.to_s)
|
15
|
+
end
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
data/lib/liquid/c/version.rb
CHANGED
data/performance.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid-c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Thacker-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|