Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 80cc930

Browse files
committed
POC of react ssr pdf vs prawn pdf
0 parents  commit 80cc930

File tree

97 files changed

+8136
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+8136
-0
lines changed

.babelrc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"modules": false,
7+
"targets": {
8+
"browsers": "> 1%",
9+
"uglify": true
10+
},
11+
"useBuiltIns": true
12+
}
13+
],
14+
"react"
15+
],
16+
"plugins": [
17+
"syntax-dynamic-import",
18+
"transform-object-rest-spread",
19+
[
20+
"transform-class-properties",
21+
{
22+
"spec": true
23+
}
24+
]
25+
]
26+
}

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all logfiles and tempfiles.
11+
/log/*
12+
/tmp/*
13+
!/log/.keep
14+
!/tmp/.keep
15+
16+
/node_modules
17+
/yarn-error.log
18+
19+
.byebug_history
20+
/public/packs
21+
/public/packs-test
22+
/node_modules

.postcssrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins:
2+
postcss-import: {}
3+
postcss-cssnext: {}

Gemfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
source 'https://rubygems.org'
2+
3+
git_source(:github) do |repo_name|
4+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5+
"https://github.com/#{repo_name}.git"
6+
end
7+
8+
gem 'bcrypt', '~> 3.1.7'
9+
gem 'pg', '~> 0.18'
10+
gem 'puma', '~> 3.7'
11+
gem 'rails', '~> 5.1.4'
12+
gem 'react-rails'
13+
gem 'sass-rails', '~> 5.0'
14+
gem 'uglifier', '>= 1.3.0'
15+
gem 'prawn'
16+
gem 'webpacker'
17+
gem 'wicked_pdf'
18+
gem 'wkhtmltopdf-binary'
19+
20+
group :development, :test do
21+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
22+
gem 'capybara', '~> 2.13'
23+
gem 'selenium-webdriver'
24+
end
25+
26+
group :development do
27+
gem 'web-console', '>= 3.3.0'
28+
end
29+
30+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (5.1.4)
5+
actionpack (= 5.1.4)
6+
nio4r (~> 2.0)
7+
websocket-driver (~> 0.6.1)
8+
actionmailer (5.1.4)
9+
actionpack (= 5.1.4)
10+
actionview (= 5.1.4)
11+
activejob (= 5.1.4)
12+
mail (~> 2.5, >= 2.5.4)
13+
rails-dom-testing (~> 2.0)
14+
actionpack (5.1.4)
15+
actionview (= 5.1.4)
16+
activesupport (= 5.1.4)
17+
rack (~> 2.0)
18+
rack-test (>= 0.6.3)
19+
rails-dom-testing (~> 2.0)
20+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21+
actionview (5.1.4)
22+
activesupport (= 5.1.4)
23+
builder (~> 3.1)
24+
erubi (~> 1.4)
25+
rails-dom-testing (~> 2.0)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
activejob (5.1.4)
28+
activesupport (= 5.1.4)
29+
globalid (>= 0.3.6)
30+
activemodel (5.1.4)
31+
activesupport (= 5.1.4)
32+
activerecord (5.1.4)
33+
activemodel (= 5.1.4)
34+
activesupport (= 5.1.4)
35+
arel (~> 8.0)
36+
activesupport (5.1.4)
37+
concurrent-ruby (~> 1.0, >= 1.0.2)
38+
i18n (~> 0.7)
39+
minitest (~> 5.1)
40+
tzinfo (~> 1.1)
41+
addressable (2.5.2)
42+
public_suffix (>= 2.0.2, < 4.0)
43+
arel (8.0.0)
44+
babel-source (5.8.35)
45+
babel-transpiler (0.7.0)
46+
babel-source (>= 4.0, < 6)
47+
execjs (~> 2.0)
48+
bcrypt (3.1.11)
49+
bindex (0.5.0)
50+
builder (3.2.3)
51+
byebug (9.1.0)
52+
capybara (2.17.0)
53+
addressable
54+
mini_mime (>= 0.1.3)
55+
nokogiri (>= 1.3.3)
56+
rack (>= 1.0.0)
57+
rack-test (>= 0.5.4)
58+
xpath (>= 2.0, < 4.0)
59+
childprocess (0.8.0)
60+
ffi (~> 1.0, >= 1.0.11)
61+
concurrent-ruby (1.0.5)
62+
connection_pool (2.2.1)
63+
crass (1.0.3)
64+
erubi (1.7.0)
65+
execjs (2.7.0)
66+
ffi (1.9.18)
67+
globalid (0.4.1)
68+
activesupport (>= 4.2.0)
69+
i18n (0.9.1)
70+
concurrent-ruby (~> 1.0)
71+
loofah (2.1.1)
72+
crass (~> 1.0.2)
73+
nokogiri (>= 1.5.9)
74+
mail (2.7.0)
75+
mini_mime (>= 0.1.1)
76+
method_source (0.9.0)
77+
mini_mime (1.0.0)
78+
mini_portile2 (2.3.0)
79+
minitest (5.11.1)
80+
nio4r (2.2.0)
81+
nokogiri (1.8.1)
82+
mini_portile2 (~> 2.3.0)
83+
pdf-core (0.7.0)
84+
pg (0.21.0)
85+
prawn (2.2.2)
86+
pdf-core (~> 0.7.0)
87+
ttfunk (~> 1.5)
88+
public_suffix (3.0.1)
89+
puma (3.11.2)
90+
rack (2.0.3)
91+
rack-proxy (0.6.3)
92+
rack
93+
rack-test (0.8.2)
94+
rack (>= 1.0, < 3)
95+
rails (5.1.4)
96+
actioncable (= 5.1.4)
97+
actionmailer (= 5.1.4)
98+
actionpack (= 5.1.4)
99+
actionview (= 5.1.4)
100+
activejob (= 5.1.4)
101+
activemodel (= 5.1.4)
102+
activerecord (= 5.1.4)
103+
activesupport (= 5.1.4)
104+
bundler (>= 1.3.0)
105+
railties (= 5.1.4)
106+
sprockets-rails (>= 2.0.0)
107+
rails-dom-testing (2.0.3)
108+
activesupport (>= 4.2.0)
109+
nokogiri (>= 1.6)
110+
rails-html-sanitizer (1.0.3)
111+
loofah (~> 2.0)
112+
railties (5.1.4)
113+
actionpack (= 5.1.4)
114+
activesupport (= 5.1.4)
115+
method_source
116+
rake (>= 0.8.7)
117+
thor (>= 0.18.1, < 2.0)
118+
rake (12.3.0)
119+
rb-fsevent (0.10.2)
120+
rb-inotify (0.9.10)
121+
ffi (>= 0.5.0, < 2)
122+
react-rails (2.4.3)
123+
babel-transpiler (>= 0.7.0)
124+
connection_pool
125+
execjs
126+
railties (>= 3.2)
127+
tilt
128+
rubyzip (1.2.1)
129+
sass (3.5.5)
130+
sass-listen (~> 4.0.0)
131+
sass-listen (4.0.0)
132+
rb-fsevent (~> 0.9, >= 0.9.4)
133+
rb-inotify (~> 0.9, >= 0.9.7)
134+
sass-rails (5.0.7)
135+
railties (>= 4.0.0, < 6)
136+
sass (~> 3.1)
137+
sprockets (>= 2.8, < 4.0)
138+
sprockets-rails (>= 2.0, < 4.0)
139+
tilt (>= 1.1, < 3)
140+
selenium-webdriver (3.8.0)
141+
childprocess (~> 0.5)
142+
rubyzip (~> 1.0)
143+
sprockets (3.7.1)
144+
concurrent-ruby (~> 1.0)
145+
rack (> 1, < 3)
146+
sprockets-rails (3.2.1)
147+
actionpack (>= 4.0)
148+
activesupport (>= 4.0)
149+
sprockets (>= 3.0.0)
150+
thor (0.20.0)
151+
thread_safe (0.3.6)
152+
tilt (2.0.8)
153+
ttfunk (1.5.1)
154+
tzinfo (1.2.4)
155+
thread_safe (~> 0.1)
156+
uglifier (4.1.3)
157+
execjs (>= 0.3.0, < 3)
158+
web-console (3.5.1)
159+
actionview (>= 5.0)
160+
activemodel (>= 5.0)
161+
bindex (>= 0.4.0)
162+
railties (>= 5.0)
163+
webpacker (3.2.0)
164+
activesupport (>= 4.2)
165+
rack-proxy (>= 0.6.1)
166+
railties (>= 4.2)
167+
websocket-driver (0.6.5)
168+
websocket-extensions (>= 0.1.0)
169+
websocket-extensions (0.1.3)
170+
wicked_pdf (1.1.0)
171+
wkhtmltopdf-binary (0.12.3.1)
172+
xpath (3.0.0)
173+
nokogiri (~> 1.8)
174+
175+
PLATFORMS
176+
ruby
177+
178+
DEPENDENCIES
179+
bcrypt (~> 3.1.7)
180+
byebug
181+
capybara (~> 2.13)
182+
pg (~> 0.18)
183+
prawn
184+
puma (~> 3.7)
185+
rails (~> 5.1.4)
186+
react-rails
187+
sass-rails (~> 5.0)
188+
selenium-webdriver
189+
tzinfo-data
190+
uglifier (>= 1.3.0)
191+
web-console (>= 3.3.0)
192+
webpacker
193+
wicked_pdf
194+
wkhtmltopdf-binary
195+
196+
BUNDLED WITH
197+
1.16.0

Procfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rails: bin/rails s -p 3000
2+
webpack: bin/webpack-dev-server
3+
maildev: bin/yarn run maildev

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# README
2+
3+
This is a proof of concept that benchmarks react-rails + wicked_pdf (server side rendered) vs prawn.
4+
5+
To get up and running:
6+
7+
* make sure you have node installed
8+
* make sure you have foreman installed ($ `gem install foreman`)
9+
* $ `bundle`
10+
* $ `foreman`
11+
12+
You then can go to [localhost:3000](http://localhost:3000) and then start sending emails and playing with the app. To view emails go to [localhost:1080](http://localhost:1080)
13+
14+
On my machine here is what I am seeing for a benchmark:
15+
16+
| PDF TYPE | user | system | total | real |
17+
|:---------|:----------:|:----------:|:----------:|:----------:|
18+
| react: | 0.030000 | 0.030000 | 1.990000 | (2.865517) |
19+
| prawn: | 0.030000 | 0.010000 | 0.040000 | (0.035425) |
20+
21+
prawn being about 75-80 times faster in rendering than react SSR rendering on my machine (quad core 2017 13" MBP). I was also seeing some pretty intense memory spikes with react SSR rendering and was not with prawn rendering (but that wasn't scientific, I was watching activity monitor turning one or the other off)
22+
23+
Also note that the react component is extremely simplistic where as the prawn template was actually doing some more complex drawing. This is intentional, it shows even more that there is a big difference between the two.

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative 'config/application'
5+
6+
Rails.application.load_tasks

app/assets/config/manifest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= link_tree ../images
2+
//= link_directory ../javascripts .js
3+
//= link_directory ../stylesheets .css

app/assets/images/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)