├── README.md
├── performance
├── README.md
├── docker-compose.yml
├── laravel_books
│ ├── .env.example
│ ├── .gitattributes
│ ├── .gitignore
│ ├── CONTRIBUTING.md
│ ├── README.mb
│ ├── ab-report.txt
│ ├── app
│ │ ├── Book.php
│ │ ├── Console
│ │ │ └── Kernel.php
│ │ ├── Exceptions
│ │ │ └── Handler.php
│ │ ├── Http
│ │ │ ├── Controllers
│ │ │ │ ├── Auth
│ │ │ │ │ ├── ForgotPasswordController.php
│ │ │ │ │ ├── LoginController.php
│ │ │ │ │ ├── RegisterController.php
│ │ │ │ │ └── ResetPasswordController.php
│ │ │ │ ├── BookController.php
│ │ │ │ └── Controller.php
│ │ │ ├── Kernel.php
│ │ │ └── Middleware
│ │ │ │ ├── EncryptCookies.php
│ │ │ │ ├── RedirectIfAuthenticated.php
│ │ │ │ ├── TrimStrings.php
│ │ │ │ └── VerifyCsrfToken.php
│ │ ├── Providers
│ │ │ ├── AppServiceProvider.php
│ │ │ ├── AuthServiceProvider.php
│ │ │ ├── BroadcastServiceProvider.php
│ │ │ ├── EventServiceProvider.php
│ │ │ └── RouteServiceProvider.php
│ │ └── User.php
│ ├── artisan
│ ├── bootstrap
│ │ ├── app.php
│ │ ├── autoload.php
│ │ └── cache
│ │ │ └── .gitignore
│ ├── composer.json
│ ├── composer.lock
│ ├── config
│ │ ├── app.php
│ │ ├── auth.php
│ │ ├── broadcasting.php
│ │ ├── cache.php
│ │ ├── database.php
│ │ ├── filesystems.php
│ │ ├── mail.php
│ │ ├── queue.php
│ │ ├── services.php
│ │ ├── session.php
│ │ └── view.php
│ ├── database
│ │ ├── .gitignore
│ │ ├── factories
│ │ │ └── ModelFactory.php
│ │ ├── migrations
│ │ │ ├── 2014_10_12_000000_create_users_table.php
│ │ │ ├── 2014_10_12_100000_create_password_resets_table.php
│ │ │ └── 2017_06_24_200949_create_books_table.php
│ │ └── seeds
│ │ │ └── DatabaseSeeder.php
│ ├── package.json
│ ├── phpunit.xml
│ ├── public
│ │ ├── .htaccess
│ │ ├── css
│ │ │ └── app.css
│ │ ├── favicon.ico
│ │ ├── index.php
│ │ ├── js
│ │ │ └── app.js
│ │ └── robots.txt
│ ├── resources
│ │ ├── assets
│ │ │ ├── js
│ │ │ │ ├── app.js
│ │ │ │ ├── bootstrap.js
│ │ │ │ └── components
│ │ │ │ │ └── Example.vue
│ │ │ └── sass
│ │ │ │ ├── _variables.scss
│ │ │ │ └── app.scss
│ │ ├── lang
│ │ │ └── en
│ │ │ │ ├── auth.php
│ │ │ │ ├── pagination.php
│ │ │ │ ├── passwords.php
│ │ │ │ └── validation.php
│ │ └── views
│ │ │ ├── books
│ │ │ └── index.blade.php
│ │ │ ├── main.blade.php
│ │ │ └── welcome.blade.php
│ ├── routes
│ │ ├── api.php
│ │ ├── channels.php
│ │ ├── console.php
│ │ └── web.php
│ ├── server.php
│ ├── storage
│ │ ├── app
│ │ │ ├── .gitignore
│ │ │ └── public
│ │ │ │ └── .gitignore
│ │ ├── framework
│ │ │ ├── .gitignore
│ │ │ ├── cache
│ │ │ │ └── .gitignore
│ │ │ ├── sessions
│ │ │ │ └── .gitignore
│ │ │ ├── testing
│ │ │ │ └── .gitignore
│ │ │ └── views
│ │ │ │ └── .gitignore
│ │ └── logs
│ │ │ └── .gitignore
│ ├── tests
│ │ ├── CreatesApplication.php
│ │ ├── Feature
│ │ │ └── ExampleTest.php
│ │ ├── TestCase.php
│ │ └── Unit
│ │ │ └── ExampleTest.php
│ ├── webpack.mix.js
│ └── yarn.lock
├── phoenix_books
│ ├── .gitignore
│ ├── CONTRIBUTING.md
│ ├── ab-report.txt
│ ├── brunch-config.js
│ ├── config
│ │ ├── config.exs
│ │ ├── dev.exs
│ │ ├── prod.exs
│ │ └── test.exs
│ ├── lib
│ │ ├── phoenix_books.ex
│ │ └── phoenix_books
│ │ │ ├── endpoint.ex
│ │ │ └── repo.ex
│ ├── mix.exs
│ ├── mix.lock
│ ├── package.json
│ ├── priv
│ │ ├── gettext
│ │ │ ├── en
│ │ │ │ └── LC_MESSAGES
│ │ │ │ │ └── errors.po
│ │ │ └── errors.pot
│ │ └── repo
│ │ │ ├── migrations
│ │ │ └── 20170125190255_create_book.exs
│ │ │ └── seeds.exs
│ ├── test
│ │ ├── controllers
│ │ │ ├── book_controller_test.exs
│ │ │ └── page_controller_test.exs
│ │ ├── models
│ │ │ └── book_test.exs
│ │ ├── support
│ │ │ ├── channel_case.ex
│ │ │ ├── conn_case.ex
│ │ │ └── model_case.ex
│ │ ├── test_helper.exs
│ │ └── views
│ │ │ ├── error_view_test.exs
│ │ │ ├── layout_view_test.exs
│ │ │ └── page_view_test.exs
│ └── web
│ │ ├── channels
│ │ └── user_socket.ex
│ │ ├── controllers
│ │ ├── book_controller.ex
│ │ └── page_controller.ex
│ │ ├── gettext.ex
│ │ ├── models
│ │ └── book.ex
│ │ ├── router.ex
│ │ ├── static
│ │ ├── assets
│ │ │ ├── favicon.ico
│ │ │ ├── images
│ │ │ │ └── phoenix.png
│ │ │ └── robots.txt
│ │ ├── css
│ │ │ ├── app.css
│ │ │ └── phoenix.css
│ │ └── js
│ │ │ ├── app.js
│ │ │ └── socket.js
│ │ ├── templates
│ │ ├── book
│ │ │ ├── edit.html.eex
│ │ │ ├── form.html.eex
│ │ │ ├── index.html.eex
│ │ │ ├── new.html.eex
│ │ │ └── show.html.eex
│ │ ├── layout
│ │ │ └── app.html.eex
│ │ └── page
│ │ │ └── index.html.eex
│ │ ├── views
│ │ ├── book_view.ex
│ │ ├── error_helpers.ex
│ │ ├── error_view.ex
│ │ ├── layout_view.ex
│ │ └── page_view.ex
│ │ └── web.ex
└── rails_books
│ ├── .gitignore
│ ├── CONTRIBUTING.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── README.md
│ ├── Rakefile
│ ├── ab-report-development.txt
│ ├── ab-report-production.txt
│ ├── app
│ ├── assets
│ │ ├── config
│ │ │ └── manifest.js
│ │ ├── images
│ │ │ └── .keep
│ │ ├── javascripts
│ │ │ ├── application.js
│ │ │ ├── books.coffee
│ │ │ ├── cable.js
│ │ │ └── channels
│ │ │ │ └── .keep
│ │ └── stylesheets
│ │ │ ├── application.css
│ │ │ ├── books.scss
│ │ │ └── scaffolds.scss
│ ├── channels
│ │ └── application_cable
│ │ │ ├── channel.rb
│ │ │ └── connection.rb
│ ├── controllers
│ │ ├── application_controller.rb
│ │ ├── books_controller.rb
│ │ └── concerns
│ │ │ └── .keep
│ ├── helpers
│ │ ├── application_helper.rb
│ │ └── books_helper.rb
│ ├── jobs
│ │ └── application_job.rb
│ ├── mailers
│ │ └── application_mailer.rb
│ ├── models
│ │ ├── application_record.rb
│ │ ├── book.rb
│ │ └── concerns
│ │ │ └── .keep
│ └── views
│ │ ├── books
│ │ ├── _book.json.jbuilder
│ │ ├── _form.html.erb
│ │ ├── edit.html.erb
│ │ ├── index.html.erb
│ │ ├── index.json.jbuilder
│ │ ├── new.html.erb
│ │ ├── show.html.erb
│ │ └── show.json.jbuilder
│ │ └── layouts
│ │ ├── application.html.erb
│ │ ├── mailer.html.erb
│ │ └── mailer.text.erb
│ ├── bin
│ ├── bundle
│ ├── rails
│ ├── rake
│ ├── setup
│ ├── spring
│ └── update
│ ├── config.ru
│ ├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── cable.yml
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── application_controller_renderer.rb
│ │ ├── assets.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── cookies_serializer.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── new_framework_defaults.rb
│ │ ├── session_store.rb
│ │ └── wrap_parameters.rb
│ ├── locales
│ │ └── en.yml
│ ├── routes.rb
│ ├── secrets.yml
│ └── spring.rb
│ ├── db
│ ├── migrate
│ │ └── 20170125190032_create_books.rb
│ ├── schema.rb
│ └── seeds.rb
│ ├── lib
│ ├── assets
│ │ └── .keep
│ └── tasks
│ │ └── .keep
│ ├── log
│ └── .keep
│ ├── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ ├── apple-touch-icon-precomposed.png
│ ├── apple-touch-icon.png
│ ├── favicon.ico
│ └── robots.txt
│ ├── test
│ ├── controllers
│ │ ├── .keep
│ │ └── books_controller_test.rb
│ ├── fixtures
│ │ ├── .keep
│ │ ├── books.yml
│ │ └── files
│ │ │ └── .keep
│ ├── helpers
│ │ └── .keep
│ ├── integration
│ │ └── .keep
│ ├── mailers
│ │ └── .keep
│ ├── models
│ │ ├── .keep
│ │ └── book_test.rb
│ └── test_helper.rb
│ ├── tmp
│ └── .keep
│ └── vendor
│ └── assets
│ ├── javascripts
│ └── .keep
│ └── stylesheets
│ └── .keep
└── produtividade
└── .gitkeep
/README.md:
--------------------------------------------------------------------------------
1 | O principal objetivo desse estudo é realizar um comparativo entre Performance e Produtividade para os principais framewords que contém o Mindset Ágil disponíveis hoje (25/06/2017).
2 |
3 | Isso é irá facilitar a escolha com relação ao Conhecimento da Equipe, Necessidade do Cliente e Requisitos do Projeto.
4 |
5 | As tecnologias e frameworks são:
6 | * Ruby/Rails (Iniciado)
7 | * Exilir/Phoenix (Iniciado)
8 | * Php/Laravel (Iniciado)
9 | * Python/Django (Não Iniciado)
10 | * Java/Play ou Grails (Não Iniciado)
11 | * Scale/Play (Não Iniciado)
12 | * Nodejs/Express ou Sails (Não Iniciado)
13 |
--------------------------------------------------------------------------------
/performance/README.md:
--------------------------------------------------------------------------------
1 | Dados
2 | --
3 | Modelo de Dados
4 |
5 | * Tabela
6 | * Books
7 |
8 | * Atributos
9 | * title
10 | * author
11 |
12 | * Dados
13 | * title: "Ready Player One" x30
14 | * author: "Ernest Cline" x30
15 |
16 |
17 | Test Performance
18 | --
19 | Rails
20 |
21 | puma -t 8:32 -w 3 -b tcp://localhost:3000 -e production
22 | ab -n 1000 -c 50 http://localhost:3000/books
23 |
24 | Connection Times (ms)
25 | min mean[+/-sd] median max
26 | Connect: 0 0 0.3 0 2
27 | Processing: 9 215 179.8 153 666
28 | Waiting: 9 215 179.8 152 666
29 | Total: 9 215 179.9 153 666
30 |
31 |
32 | Phoenix
33 |
34 | mix phoenix.server
35 | ab -n 1000 -c 50 http://localhost:4000/books
36 |
37 | Connection Times (ms)
38 | min mean[+/-sd] median max
39 | Connect: 0 0 0.2 0 1
40 | Processing: 27 92 23.6 93 155
41 | Waiting: 27 92 23.6 93 155
42 | Total: 27 92 23.6 93 156
43 |
44 |
45 | Laravel
46 |
47 | php artisan serve
48 | ab -n 1000 -c 50 http://localhost:8000/books
49 |
50 | Connection Times (ms)
51 | min mean[+/-sd] median max
52 | Connect: 0 0 0.2 0 1
53 | Processing: 87 499 64.4 494 648
54 | Waiting: 86 498 64.3 493 647
55 | Total: 88 499 64.2 494 648
56 |
57 |
--------------------------------------------------------------------------------
/performance/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | postgres:
5 | container_name: postgres_performance
6 | image: postgres:9.5
7 | ports:
8 | - 5432:5432
9 | environment:
10 | POSTGRES_PASSWORD: postgres
11 | volumes:
12 | - /opt/postgresql:/var/lib/postgresql
13 |
--------------------------------------------------------------------------------
/performance/laravel_books/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_LOG_LEVEL=debug
6 | APP_URL=http://localhost
7 |
8 | DB_CONNECTION=mysql
9 | DB_HOST=127.0.0.1
10 | DB_PORT=3306
11 | DB_DATABASE=homestead
12 | DB_USERNAME=homestead
13 | DB_PASSWORD=secret
14 |
15 | BROADCAST_DRIVER=log
16 | CACHE_DRIVER=file
17 | SESSION_DRIVER=file
18 | QUEUE_DRIVER=sync
19 |
20 | REDIS_HOST=127.0.0.1
21 | REDIS_PASSWORD=null
22 | REDIS_PORT=6379
23 |
24 | MAIL_DRIVER=smtp
25 | MAIL_HOST=smtp.mailtrap.io
26 | MAIL_PORT=2525
27 | MAIL_USERNAME=null
28 | MAIL_PASSWORD=null
29 | MAIL_ENCRYPTION=null
30 |
31 | PUSHER_APP_ID=
32 | PUSHER_APP_KEY=
33 | PUSHER_APP_SECRET=
34 |
--------------------------------------------------------------------------------
/performance/laravel_books/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/performance/laravel_books/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | /.idea
7 | /.vagrant
8 | Homestead.json
9 | Homestead.yaml
10 | npm-debug.log
11 | .env
12 |
--------------------------------------------------------------------------------
/performance/laravel_books/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Laravel
2 | --
3 | Dependency
4 |
5 | > cd laravel_books
6 |
7 | Seed
8 | > php artisan migrate
9 | > php artisan db:seed
10 |
11 | Starting
12 | > php artisan serve
13 |
--------------------------------------------------------------------------------
/performance/laravel_books/README.mb:
--------------------------------------------------------------------------------
1 | Instalar
2 | --
3 | > sudo apt-get install php7.0-cli php-mcrypt php-gd php-mbstring php7.0-zip php7.0-xml php7.0-pgsql postgresql-client
4 |
5 | > curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
6 |
7 | > export PATH="$PATH:$HOME/.composer/vendor/bin"
8 |
9 | > composer global require "laravel/installer"
10 |
11 | > psql -h hostname -U postgres
12 |
13 | > CREATE DATABASE laravel_books_development;
14 |
--------------------------------------------------------------------------------
/performance/laravel_books/ab-report.txt:
--------------------------------------------------------------------------------
1 | php artisan serve
2 | ab -n 1000 -c 50 http://localhost:8000/books
3 | Benchmarking localhost (be patient)
4 | Completed 100 requests
5 | Completed 200 requests
6 | Completed 300 requests
7 | Completed 400 requests
8 | Completed 500 requests
9 | Completed 600 requests
10 | Completed 700 requests
11 | Completed 800 requests
12 | Completed 900 requests
13 | Completed 1000 requests
14 | Finished 1000 requests
15 |
16 |
17 | Server Software:
18 | Server Hostname: localhost
19 | Server Port: 8000
20 |
21 | Document Path: /books
22 | Document Length: 10374 bytes
23 |
24 | Concurrency Level: 50
25 | Time taken for tests: 10.227 seconds
26 | Complete requests: 1000
27 | Failed requests: 0
28 | Total transferred: 11370968 bytes
29 | HTML transferred: 10374000 bytes
30 | Requests per second: 97.78 [#/sec] (mean)
31 | Time per request: 511.366 [ms] (mean)
32 | Time per request: 10.227 [ms] (mean, across all concurrent requests)
33 | Transfer rate: 1085.76 [Kbytes/sec] received
34 |
35 | Connection Times (ms)
36 | min mean[+/-sd] median max
37 | Connect: 0 0 0.2 0 1
38 | Processing: 87 499 64.4 494 648
39 | Waiting: 86 498 64.3 493 647
40 | Total: 88 499 64.2 494 648
41 |
42 | Percentage of the requests served within a certain time (ms)
43 | 50% 494
44 | 66% 500
45 | 75% 511
46 | 80% 518
47 | 90% 559
48 | 95% 609
49 | 98% 639
50 | 99% 646
51 | 100% 648 (longest request)
52 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Book.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the Closure based commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | require base_path('routes/console.php');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
60 | return response()->json(['error' => 'Unauthenticated.'], 401);
61 | }
62 |
63 | return redirect()->guest(route('login'));
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/Auth/ForgotPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
40 | }
41 |
42 | /**
43 | * Get a validator for an incoming registration request.
44 | *
45 | * @param array $data
46 | * @return \Illuminate\Contracts\Validation\Validator
47 | */
48 | protected function validator(array $data)
49 | {
50 | return Validator::make($data, [
51 | 'name' => 'required|string|max:255',
52 | 'email' => 'required|string|email|max:255|unique:users',
53 | 'password' => 'required|string|min:6|confirmed',
54 | ]);
55 | }
56 |
57 | /**
58 | * Create a new user instance after a valid registration.
59 | *
60 | * @param array $data
61 | * @return User
62 | */
63 | protected function create(array $data)
64 | {
65 | return User::create([
66 | 'name' => $data['name'],
67 | 'email' => $data['email'],
68 | 'password' => bcrypt($data['password']),
69 | ]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/BookController.php:
--------------------------------------------------------------------------------
1 | withBooks($books);
20 | }
21 |
22 | /**
23 | * Show the form for creating a new resource.
24 | *
25 | * @return \Illuminate\Http\Response
26 | */
27 | public function create()
28 | {
29 | //
30 | }
31 |
32 | /**
33 | * Store a newly created resource in storage.
34 | *
35 | * @param \Illuminate\Http\Request $request
36 | * @return \Illuminate\Http\Response
37 | */
38 | public function store(Request $request)
39 | {
40 | //
41 | }
42 |
43 | /**
44 | * Display the specified resource.
45 | *
46 | * @param int $id
47 | * @return \Illuminate\Http\Response
48 | */
49 | public function show($id)
50 | {
51 | //
52 | }
53 |
54 | /**
55 | * Show the form for editing the specified resource.
56 | *
57 | * @param int $id
58 | * @return \Illuminate\Http\Response
59 | */
60 | public function edit($id)
61 | {
62 | //
63 | }
64 |
65 | /**
66 | * Update the specified resource in storage.
67 | *
68 | * @param \Illuminate\Http\Request $request
69 | * @param int $id
70 | * @return \Illuminate\Http\Response
71 | */
72 | public function update(Request $request, $id)
73 | {
74 | //
75 | }
76 |
77 | /**
78 | * Remove the specified resource from storage.
79 | *
80 | * @param int $id
81 | * @return \Illuminate\Http\Response
82 | */
83 | public function destroy($id)
84 | {
85 | //
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | [
30 | \App\Http\Middleware\EncryptCookies::class,
31 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32 | \Illuminate\Session\Middleware\StartSession::class,
33 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
34 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
35 | \App\Http\Middleware\VerifyCsrfToken::class,
36 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
37 | ],
38 |
39 | 'api' => [
40 | 'throttle:60,1',
41 | 'bindings',
42 | ],
43 | ];
44 |
45 | /**
46 | * The application's route middleware.
47 | *
48 | * These middleware may be assigned to groups or used individually.
49 | *
50 | * @var array
51 | */
52 | protected $routeMiddleware = [
53 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
55 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
57 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
58 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
59 | ];
60 | }
61 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | *
22 | * @return void
23 | */
24 | public function boot()
25 | {
26 | $this->registerPolicies();
27 |
28 | //
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/performance/laravel_books/app/User.php:
--------------------------------------------------------------------------------
1 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running, we will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/performance/laravel_books/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/performance/laravel_books/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | =5.6.4",
9 | "laravel/framework": "5.4.*",
10 | "laravel/tinker": "~1.0"
11 | },
12 | "require-dev": {
13 | "fzaninotto/faker": "~1.4",
14 | "mockery/mockery": "0.9.*",
15 | "phpunit/phpunit": "~5.7"
16 | },
17 | "autoload": {
18 | "classmap": [
19 | "database"
20 | ],
21 | "psr-4": {
22 | "App\\": "app/"
23 | }
24 | },
25 | "autoload-dev": {
26 | "psr-4": {
27 | "Tests\\": "tests/"
28 | }
29 | },
30 | "scripts": {
31 | "post-root-package-install": [
32 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
33 | ],
34 | "post-create-project-cmd": [
35 | "php artisan key:generate"
36 | ],
37 | "post-install-cmd": [
38 | "Illuminate\\Foundation\\ComposerScripts::postInstall",
39 | "php artisan optimize"
40 | ],
41 | "post-update-cmd": [
42 | "Illuminate\\Foundation\\ComposerScripts::postUpdate",
43 | "php artisan optimize"
44 | ]
45 | },
46 | "config": {
47 | "preferred-install": "dist",
48 | "sort-packages": true,
49 | "optimize-autoloader": true
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | 'null' => [
53 | 'driver' => 'null',
54 | ],
55 |
56 | ],
57 |
58 | ];
59 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache/data'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
55 | 'sasl' => [
56 | env('MEMCACHED_USERNAME'),
57 | env('MEMCACHED_PASSWORD'),
58 | ],
59 | 'options' => [
60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
61 | ],
62 | 'servers' => [
63 | [
64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
65 | 'port' => env('MEMCACHED_PORT', 11211),
66 | 'weight' => 100,
67 | ],
68 | ],
69 | ],
70 |
71 | 'redis' => [
72 | 'driver' => 'redis',
73 | 'connection' => 'default',
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Cache Key Prefix
81 | |--------------------------------------------------------------------------
82 | |
83 | | When utilizing a RAM based store such as APC or Memcached, there might
84 | | be other applications utilizing the same cache. So, we'll specify a
85 | | value to get prefixed to all our keys so we can avoid collisions.
86 | |
87 | */
88 |
89 | 'prefix' => 'laravel',
90 |
91 | ];
92 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Database Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here are each of the database connections setup for your application.
24 | | Of course, examples of configuring each database platform that is
25 | | supported by Laravel is shown below to make development simple.
26 | |
27 | |
28 | | All database work in Laravel is done through the PHP PDO facilities
29 | | so make sure you have the driver for your particular database of
30 | | choice installed on your machine before you begin development.
31 | |
32 | */
33 |
34 | 'connections' => [
35 |
36 | 'sqlite' => [
37 | 'driver' => 'sqlite',
38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
39 | 'prefix' => '',
40 | ],
41 |
42 | 'mysql' => [
43 | 'driver' => 'mysql',
44 | 'host' => env('DB_HOST', '127.0.0.1'),
45 | 'port' => env('DB_PORT', '3306'),
46 | 'database' => env('DB_DATABASE', 'forge'),
47 | 'username' => env('DB_USERNAME', 'forge'),
48 | 'password' => env('DB_PASSWORD', ''),
49 | 'unix_socket' => env('DB_SOCKET', ''),
50 | 'charset' => 'utf8mb4',
51 | 'collation' => 'utf8mb4_unicode_ci',
52 | 'prefix' => '',
53 | 'strict' => true,
54 | 'engine' => null,
55 | ],
56 |
57 | 'pgsql' => [
58 | 'driver' => 'pgsql',
59 | 'host' => env('DB_HOST', '127.0.0.1'),
60 | 'port' => env('DB_PORT', '5432'),
61 | 'database' => env('DB_DATABASE', 'forge'),
62 | 'username' => env('DB_USERNAME', 'forge'),
63 | 'password' => env('DB_PASSWORD', ''),
64 | 'charset' => 'utf8',
65 | 'prefix' => '',
66 | 'schema' => 'public',
67 | 'sslmode' => 'prefer',
68 | ],
69 |
70 | 'sqlsrv' => [
71 | 'driver' => 'sqlsrv',
72 | 'host' => env('DB_HOST', 'localhost'),
73 | 'port' => env('DB_PORT', '1433'),
74 | 'database' => env('DB_DATABASE', 'forge'),
75 | 'username' => env('DB_USERNAME', 'forge'),
76 | 'password' => env('DB_PASSWORD', ''),
77 | 'charset' => 'utf8',
78 | 'prefix' => '',
79 | ],
80 |
81 | ],
82 |
83 | /*
84 | |--------------------------------------------------------------------------
85 | | Migration Repository Table
86 | |--------------------------------------------------------------------------
87 | |
88 | | This table keeps track of all the migrations that have already run for
89 | | your application. Using this information, we can determine which of
90 | | the migrations on disk haven't actually been run in the database.
91 | |
92 | */
93 |
94 | 'migrations' => 'migrations',
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Redis Databases
99 | |--------------------------------------------------------------------------
100 | |
101 | | Redis is an open source, fast, and advanced key-value store that also
102 | | provides a richer set of commands than a typical key-value systems
103 | | such as APC or Memcached. Laravel makes it easy to dig right in.
104 | |
105 | */
106 |
107 | 'redis' => [
108 |
109 | 'client' => 'predis',
110 |
111 | 'default' => [
112 | 'host' => env('REDIS_HOST', '127.0.0.1'),
113 | 'password' => env('REDIS_PASSWORD', null),
114 | 'port' => env('REDIS_PORT', 6379),
115 | 'database' => 0,
116 | ],
117 |
118 | ],
119 |
120 | ];
121 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_KEY'),
61 | 'secret' => env('AWS_SECRET'),
62 | 'region' => env('AWS_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | ],
65 |
66 | ],
67 |
68 | ];
69 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | ];
124 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => 'your-public-key',
54 | 'secret' => 'your-secret-key',
55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
56 | 'queue' => 'your-queue-name',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'retry_after' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/performance/laravel_books/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker\Generator $faker) {
16 | static $password;
17 |
18 | return [
19 | 'name' => $faker->name,
20 | 'email' => $faker->unique()->safeEmail,
21 | 'password' => $password ?: $password = bcrypt('secret'),
22 | 'remember_token' => str_random(10),
23 | ];
24 | });
25 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('name');
19 | $table->string('email')->unique();
20 | $table->string('password');
21 | $table->rememberToken();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('users');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/migrations/2017_06_24_200949_create_books_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('title');
19 | $table->string('author');
20 | $table->timestamps();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::drop('books');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/performance/laravel_books/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | insert([
16 | 'title' => 'Ready Player One',
17 | 'author' => 'Ernest Cline'
18 | ]);
19 | DB::table('books')->insert([
20 | 'title' => 'Rails for dummies',
21 | 'author' => 'Alex Kovshovik'
22 | ]);
23 | DB::table('books')->insert([
24 | 'title' => 'Benefits mode easy',
25 | 'author' => 'Jim Scott'
26 | ]);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/performance/laravel_books/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.15.3",
14 | "bootstrap-sass": "^3.3.7",
15 | "cross-env": "^3.2.3",
16 | "jquery": "^3.1.1",
17 | "laravel-mix": "^1.0",
18 | "lodash": "^4.17.4",
19 | "vue": "^2.1.10"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/performance/laravel_books/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 | ./tests/Feature
14 |
15 |
16 |
17 | ./tests/Unit
18 |
19 |
20 |
21 |
22 | ./app
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/performance/laravel_books/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Redirect Trailing Slashes If Not A Folder...
9 | RewriteCond %{REQUEST_FILENAME} !-d
10 | RewriteRule ^(.*)/$ /$1 [L,R=301]
11 |
12 | # Handle Front Controller...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_FILENAME} !-f
15 | RewriteRule ^ index.php [L]
16 |
17 | # Handle Authorization Header
18 | RewriteCond %{HTTP:Authorization} .
19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
20 |
21 |
--------------------------------------------------------------------------------
/performance/laravel_books/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/laravel_books/public/favicon.ico
--------------------------------------------------------------------------------
/performance/laravel_books/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | /*
11 | |--------------------------------------------------------------------------
12 | | Register The Auto Loader
13 | |--------------------------------------------------------------------------
14 | |
15 | | Composer provides a convenient, automatically generated class loader for
16 | | our application. We just need to utilize it! We'll simply require it
17 | | into the script here so that we don't have to worry about manual
18 | | loading any of our classes later on. It feels great to relax.
19 | |
20 | */
21 |
22 | require __DIR__.'/../bootstrap/autoload.php';
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Turn On The Lights
27 | |--------------------------------------------------------------------------
28 | |
29 | | We need to illuminate PHP development, so let us turn on the lights.
30 | | This bootstraps the framework and gets it ready for use, then it
31 | | will load up this application so that we can run it and send
32 | | the responses back to the browser and delight our users.
33 | |
34 | */
35 |
36 | $app = require_once __DIR__.'/../bootstrap/app.php';
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Run The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once we have the application, we can handle the incoming request
44 | | through the kernel, and send the associated response back to
45 | | the client's browser allowing them to enjoy the creative
46 | | and wonderful application we have prepared for them.
47 | |
48 | */
49 |
50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51 |
52 | $response = $kernel->handle(
53 | $request = Illuminate\Http\Request::capture()
54 | );
55 |
56 | $response->send();
57 |
58 | $kernel->terminate($request, $response);
59 |
--------------------------------------------------------------------------------
/performance/laravel_books/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/assets/js/app.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * First we will load all of this project's JavaScript dependencies which
4 | * includes Vue and other libraries. It is a great starting point when
5 | * building robust, powerful web applications using Vue and Laravel.
6 | */
7 |
8 | require('./bootstrap');
9 |
10 | window.Vue = require('vue');
11 |
12 | /**
13 | * Next, we will create a fresh Vue application instance and attach it to
14 | * the page. Then, you may begin adding components to this application
15 | * or customize the JavaScript scaffolding to fit your unique needs.
16 | */
17 |
18 | Vue.component('example', require('./components/Example.vue'));
19 |
20 | const app = new Vue({
21 | el: '#app'
22 | });
23 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/assets/js/bootstrap.js:
--------------------------------------------------------------------------------
1 |
2 | window._ = require('lodash');
3 |
4 | /**
5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support
6 | * for JavaScript based Bootstrap features such as modals and tabs. This
7 | * code may be modified to fit the specific needs of your application.
8 | */
9 |
10 | try {
11 | window.$ = window.jQuery = require('jquery');
12 |
13 | require('bootstrap-sass');
14 | } catch (e) {}
15 |
16 | /**
17 | * We'll load the axios HTTP library which allows us to easily issue requests
18 | * to our Laravel back-end. This library automatically handles sending the
19 | * CSRF token as a header based on the value of the "XSRF" token cookie.
20 | */
21 |
22 | window.axios = require('axios');
23 |
24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
25 |
26 | /**
27 | * Next we will register the CSRF Token as a common header with Axios so that
28 | * all outgoing HTTP requests automatically have it attached. This is just
29 | * a simple convenience so we don't have to attach every token manually.
30 | */
31 |
32 | let token = document.head.querySelector('meta[name="csrf-token"]');
33 |
34 | if (token) {
35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
36 | } else {
37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
38 | }
39 |
40 | /**
41 | * Echo exposes an expressive API for subscribing to channels and listening
42 | * for events that are broadcast by Laravel. Echo and event broadcasting
43 | * allows your team to easily build robust real-time web applications.
44 | */
45 |
46 | // import Echo from 'laravel-echo'
47 |
48 | // window.Pusher = require('pusher-js');
49 |
50 | // window.Echo = new Echo({
51 | // broadcaster: 'pusher',
52 | // key: 'your-pusher-key'
53 | // });
54 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/assets/js/components/Example.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Example Component
7 |
8 |
9 | I'm an example component!
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/assets/sass/_variables.scss:
--------------------------------------------------------------------------------
1 |
2 | // Body
3 | $body-bg: #f5f8fa;
4 |
5 | // Borders
6 | $laravel-border-color: darken($body-bg, 10%);
7 | $list-group-border: $laravel-border-color;
8 | $navbar-default-border: $laravel-border-color;
9 | $panel-default-border: $laravel-border-color;
10 | $panel-inner-border: $laravel-border-color;
11 |
12 | // Brands
13 | $brand-primary: #3097D1;
14 | $brand-info: #8eb4cb;
15 | $brand-success: #2ab27b;
16 | $brand-warning: #cbb956;
17 | $brand-danger: #bf5329;
18 |
19 | // Typography
20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
21 | $font-family-sans-serif: "Raleway", sans-serif;
22 | $font-size-base: 14px;
23 | $line-height-base: 1.6;
24 | $text-color: #636b6f;
25 |
26 | // Navbar
27 | $navbar-default-bg: #fff;
28 |
29 | // Buttons
30 | $btn-default-color: $text-color;
31 |
32 | // Inputs
33 | $input-border: lighten($text-color, 40%);
34 | $input-border-focus: lighten($brand-primary, 25%);
35 | $input-color-placeholder: lighten($text-color, 30%);
36 |
37 | // Panels
38 | $panel-default-heading-bg: #fff;
39 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/assets/sass/app.scss:
--------------------------------------------------------------------------------
1 |
2 | // Fonts
3 | @import url("https://fonts.googleapis.com/css?family=Raleway:300,400,600");
4 |
5 | // Variables
6 | @import "variables";
7 |
8 | // Bootstrap
9 | @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
10 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
17 | 'reset' => 'Your password has been reset!',
18 | 'sent' => 'We have e-mailed your password reset link!',
19 | 'token' => 'This password reset token is invalid.',
20 | 'user' => "We can't find a user with that e-mail address.",
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/views/books/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('main')
2 |
3 | @section('title', '| All Books')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
All Books
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | #
25 | Title
26 | Author
27 | Created At
28 |
29 |
30 |
31 |
32 |
33 | @foreach ($books as $book)
34 |
35 |
36 | {{ $book->id }}
37 | {{ $book->title }}
38 | {{ $book->author }}
39 | {{ date('M j, Y', strtotime($book->created_at)) }}
40 | View Edit
41 |
42 |
43 | @endforeach
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | @stop
53 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/views/main.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | @yield('content')
8 |
9 | @yield('scripts')
10 |
11 |
12 |
--------------------------------------------------------------------------------
/performance/laravel_books/resources/views/welcome.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Laravel
9 |
10 |
11 |
12 |
13 |
14 |
66 |
67 |
68 |
69 | @if (Route::has('login'))
70 |
71 | @if (Auth::check())
72 |
Home
73 | @else
74 |
Login
75 |
Register
76 | @endif
77 |
78 | @endif
79 |
80 |
81 |
82 | Laravel
83 |
84 |
85 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/performance/laravel_books/routes/api.php:
--------------------------------------------------------------------------------
1 | get('/user', function (Request $request) {
17 | return $request->user();
18 | });
19 |
--------------------------------------------------------------------------------
/performance/laravel_books/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
16 | });
17 |
--------------------------------------------------------------------------------
/performance/laravel_books/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
18 | })->describe('Display an inspiring quote');
19 |
--------------------------------------------------------------------------------
/performance/laravel_books/routes/web.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | $uri = urldecode(
11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
12 | );
13 |
14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
15 | // built-in PHP web server. This provides a convenient way to test a Laravel
16 | // application without having installed a "real" web server software here.
17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
18 | return false;
19 | }
20 |
21 | require_once __DIR__.'/public/index.php';
22 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/app/public/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | config.php
2 | routes.php
3 | schedule-*
4 | compiled.php
5 | services.json
6 | events.scanned.php
7 | routes.scanned.php
8 | down
9 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/performance/laravel_books/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
19 |
20 | return $app;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/performance/laravel_books/tests/Feature/ExampleTest.php:
--------------------------------------------------------------------------------
1 | get('/');
20 |
21 | $response->assertStatus(200);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/performance/laravel_books/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/performance/laravel_books/webpack.mix.js:
--------------------------------------------------------------------------------
1 | let mix = require('laravel-mix');
2 |
3 | /*
4 | |--------------------------------------------------------------------------
5 | | Mix Asset Management
6 | |--------------------------------------------------------------------------
7 | |
8 | | Mix provides a clean, fluent API for defining some Webpack build steps
9 | | for your Laravel application. By default, we are compiling the Sass
10 | | file for the application as well as bundling up all the JS files.
11 | |
12 | */
13 |
14 | mix.js('resources/assets/js/app.js', 'public/js')
15 | .sass('resources/assets/sass/app.scss', 'public/css');
16 |
--------------------------------------------------------------------------------
/performance/phoenix_books/.gitignore:
--------------------------------------------------------------------------------
1 | # App artifacts
2 | /_build
3 | /db
4 | /deps
5 | /*.ez
6 |
7 | # Generated on crash by the VM
8 | erl_crash.dump
9 |
10 | # Static artifacts
11 | /node_modules
12 |
13 | # Since we are building assets from web/static,
14 | # we ignore priv/static. You may want to comment
15 | # this depending on your deployment strategy.
16 | /priv/static/
17 |
18 | # The config/prod.secret.exs file by default contains sensitive
19 | # data and you should not commit it into version control.
20 | #
21 | # Alternatively, you may comment the line below and commit the
22 | # secrets file as long as you replace its contents by environment
23 | # variables.
24 | /config/prod.secret.exs
25 |
--------------------------------------------------------------------------------
/performance/phoenix_books/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Phoenix
2 | --
3 |
4 | Dependency
5 |
6 | > cd phoenix_books
7 |
8 | > npm install
9 |
10 | > mix deps.get
11 |
12 | Seed
13 | > mix ecto.drop ecto.create ecto.migrate
14 | > mix run priv/repo/seeds.exs
15 |
16 | Starting
17 | > mix phoenix.server
18 |
--------------------------------------------------------------------------------
/performance/phoenix_books/ab-report.txt:
--------------------------------------------------------------------------------
1 | mix phoenix.server
2 | ab -n 1000 -c 50 http://localhost:4000/books
3 | Benchmarking localhost (be patient)
4 | Completed 100 requests
5 | Completed 200 requests
6 | Completed 300 requests
7 | Completed 400 requests
8 | Completed 500 requests
9 | Completed 600 requests
10 | Completed 700 requests
11 | Completed 800 requests
12 | Completed 900 requests
13 | Completed 1000 requests
14 | Finished 1000 requests
15 |
16 | Server Software:
17 | Server Hostname: localhost
18 | Server Port: 4000
19 |
20 | Document Path: /books
21 | Document Length: 18782 bytes
22 |
23 | Concurrency Level: 50
24 | Time taken for tests: 1.881 seconds
25 | Complete requests: 1000
26 | Failed requests: 0
27 | Total transferred: 19283000 bytes
28 | HTML transferred: 18782000 bytes
29 | Requests per second: 531.72 [#/sec] (mean)
30 | Time per request: 94.034 [ms] (mean)
31 | Time per request: 1.881 [ms] (mean, across all concurrent requests)
32 | Transfer rate: 10012.88 [Kbytes/sec] received
33 |
34 | Connection Times (ms)
35 | min mean[+/-sd] median max
36 | Connect: 0 0 0.2 0 1
37 | Processing: 27 92 23.6 93 155
38 | Waiting: 27 92 23.6 93 155
39 | Total: 27 92 23.6 93 156
40 |
41 | Percentage of the requests served within a certain time (ms)
42 | 50% 93
43 | 66% 102
44 | 75% 108
45 | 80% 112
46 | 90% 122
47 | 95% 129
48 | 98% 141
49 | 99% 146
50 | 100% 156 (longest request)
51 |
52 | ab -n 100000 -c 500 http://localhost:4000/books
53 | Benchmarking localhost (be patient)
54 | Completed 10000 requests
55 | Completed 20000 requests
56 | Completed 30000 requests
57 | Completed 40000 requests
58 | Completed 50000 requests
59 | Completed 60000 requests
60 | Completed 70000 requests
61 | Completed 80000 requests
62 | Completed 90000 requests
63 | Completed 100000 requests
64 | Finished 100000 requests
65 |
66 |
67 | Server Software:
68 | Server Hostname: localhost
69 | Server Port: 4000
70 |
71 | Document Path: /books
72 | Document Length: 18782 bytes
73 |
74 | Concurrency Level: 500
75 | Time taken for tests: 202.557 seconds
76 | Complete requests: 100000
77 | Failed requests: 0
78 | Total transferred: 1928300000 bytes
79 | HTML transferred: 1878200000 bytes
80 | Requests per second: 493.69 [#/sec] (mean)
81 | Time per request: 1012.786 [ms] (mean)
82 | Time per request: 2.026 [ms] (mean, across all concurrent requests)
83 | Transfer rate: 9296.66 [Kbytes/sec] received
84 |
85 | Connection Times (ms)
86 | min mean[+/-sd] median max
87 | Connect: 0 3 52.0 0 1003
88 | Processing: 63 1008 271.0 1013 2446
89 | Waiting: 63 1008 271.0 1012 2446
90 | Total: 63 1010 273.6 1014 2446
91 |
92 | Percentage of the requests served within a certain time (ms)
93 | 50% 1014
94 | 66% 1119
95 | 75% 1186
96 | 80% 1226
97 | 90% 1350
98 | 95% 1464
99 | 98% 1589
100 | 99% 1675
101 | 100% 2446 (longest request)
102 |
--------------------------------------------------------------------------------
/performance/phoenix_books/brunch-config.js:
--------------------------------------------------------------------------------
1 | exports.config = {
2 | // See http://brunch.io/#documentation for docs.
3 | files: {
4 | javascripts: {
5 | joinTo: "js/app.js"
6 |
7 | // To use a separate vendor.js bundle, specify two files path
8 | // http://brunch.io/docs/config#-files-
9 | // joinTo: {
10 | // "js/app.js": /^(web\/static\/js)/,
11 | // "js/vendor.js": /^(web\/static\/vendor)|(deps)/
12 | // }
13 | //
14 | // To change the order of concatenation of files, explicitly mention here
15 | // order: {
16 | // before: [
17 | // "web/static/vendor/js/jquery-2.1.1.js",
18 | // "web/static/vendor/js/bootstrap.min.js"
19 | // ]
20 | // }
21 | },
22 | stylesheets: {
23 | joinTo: "css/app.css",
24 | order: {
25 | after: ["web/static/css/app.css"] // concat app.css last
26 | }
27 | },
28 | templates: {
29 | joinTo: "js/app.js"
30 | }
31 | },
32 |
33 | conventions: {
34 | // This option sets where we should place non-css and non-js assets in.
35 | // By default, we set this to "/web/static/assets". Files in this directory
36 | // will be copied to `paths.public`, which is "priv/static" by default.
37 | assets: /^(web\/static\/assets)/
38 | },
39 |
40 | // Phoenix paths configuration
41 | paths: {
42 | // Dependencies and current project directories to watch
43 | watched: [
44 | "web/static",
45 | "test/static"
46 | ],
47 |
48 | // Where to compile files to
49 | public: "priv/static"
50 | },
51 |
52 | // Configure your plugins
53 | plugins: {
54 | babel: {
55 | // Do not use ES6 compiler in vendor code
56 | ignore: [/web\/static\/vendor/]
57 | }
58 | },
59 |
60 | modules: {
61 | autoRequire: {
62 | "js/app.js": ["web/static/js/app"]
63 | }
64 | },
65 |
66 | npm: {
67 | enabled: true
68 | }
69 | };
70 |
--------------------------------------------------------------------------------
/performance/phoenix_books/config/config.exs:
--------------------------------------------------------------------------------
1 | # This file is responsible for configuring your application
2 | # and its dependencies with the aid of the Mix.Config module.
3 | #
4 | # This configuration file is loaded before any dependency and
5 | # is restricted to this project.
6 | use Mix.Config
7 |
8 | # General application configuration
9 | config :phoenix_books,
10 | ecto_repos: [PhoenixBooks.Repo]
11 |
12 | # Configures the endpoint
13 | config :phoenix_books, PhoenixBooks.Endpoint,
14 | url: [host: "localhost"],
15 | secret_key_base: "lOMsYvY08XsmGoY51TwmnkBLPYH2AjAoycHAJpzzCe7QQfJh2mTs3UsWfyxJQ53e",
16 | render_errors: [view: PhoenixBooks.ErrorView, accepts: ~w(html json)],
17 | pubsub: [name: PhoenixBooks.PubSub,
18 | adapter: Phoenix.PubSub.PG2]
19 |
20 | # Configures Elixir's Logger
21 | config :logger, :console,
22 | format: "$time $metadata[$level] $message\n",
23 | metadata: [:request_id]
24 |
25 | # Import environment specific config. This must remain at the bottom
26 | # of this file so it overrides the configuration defined above.
27 | import_config "#{Mix.env}.exs"
28 |
--------------------------------------------------------------------------------
/performance/phoenix_books/config/dev.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # For development, we disable any cache and enable
4 | # debugging and code reloading.
5 | #
6 | # The watchers configuration can be used to run external
7 | # watchers to your application. For example, we use it
8 | # with brunch.io to recompile .js and .css sources.
9 | config :phoenix_books, PhoenixBooks.Endpoint,
10 | http: [port: 4000],
11 | debug_errors: true,
12 | code_reloader: true,
13 | check_origin: false,
14 | watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
15 | cd: Path.expand("../", __DIR__)]]
16 |
17 |
18 | # Watch static and templates for browser reloading.
19 | config :phoenix_books, PhoenixBooks.Endpoint,
20 | live_reload: [
21 | patterns: [
22 | ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
23 | ~r{priv/gettext/.*(po)$},
24 | ~r{web/views/.*(ex)$},
25 | ~r{web/templates/.*(eex)$}
26 | ]
27 | ]
28 |
29 | # Do not include metadata nor timestamps in development logs
30 | config :logger, :console, format: "[$level] $message\n"
31 |
32 | # Set a higher stacktrace during development. Avoid configuring such
33 | # in production as building large stacktraces may be expensive.
34 | config :phoenix, :stacktrace_depth, 20
35 |
36 | # Configure your database
37 | config :phoenix_books, PhoenixBooks.Repo,
38 | adapter: Ecto.Adapters.Postgres,
39 | username: "postgres",
40 | password: "postgres",
41 | database: "phoenix_books_development",
42 | hostname: "localhost",
43 | pool_size: 10
44 |
--------------------------------------------------------------------------------
/performance/phoenix_books/config/prod.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # For production, we configure the host to read the PORT
4 | # from the system environment. Therefore, you will need
5 | # to set PORT=80 before running your server.
6 | #
7 | # You should also configure the url host to something
8 | # meaningful, we use this information when generating URLs.
9 | #
10 | # Finally, we also include the path to a manifest
11 | # containing the digested version of static files. This
12 | # manifest is generated by the mix phoenix.digest task
13 | # which you typically run after static files are built.
14 | config :phoenix_books, PhoenixBooks.Endpoint,
15 | http: [port: {:system, "PORT"}],
16 | url: [host: "example.com", port: 80],
17 | cache_static_manifest: "priv/static/manifest.json"
18 |
19 | # Do not print debug messages in production
20 | config :logger, level: :info
21 |
22 | # ## SSL Support
23 | #
24 | # To get SSL working, you will need to add the `https` key
25 | # to the previous section and set your `:url` port to 443:
26 | #
27 | # config :phoenix_books, PhoenixBooks.Endpoint,
28 | # ...
29 | # url: [host: "example.com", port: 443],
30 | # https: [port: 443,
31 | # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
32 | # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
33 | #
34 | # Where those two env variables return an absolute path to
35 | # the key and cert in disk or a relative path inside priv,
36 | # for example "priv/ssl/server.key".
37 | #
38 | # We also recommend setting `force_ssl`, ensuring no data is
39 | # ever sent via http, always redirecting to https:
40 | #
41 | # config :phoenix_books, PhoenixBooks.Endpoint,
42 | # force_ssl: [hsts: true]
43 | #
44 | # Check `Plug.SSL` for all available options in `force_ssl`.
45 |
46 | # ## Using releases
47 | #
48 | # If you are doing OTP releases, you need to instruct Phoenix
49 | # to start the server for all endpoints:
50 | #
51 | # config :phoenix, :serve_endpoints, true
52 | #
53 | # Alternatively, you can configure exactly which server to
54 | # start per endpoint:
55 | #
56 | # config :phoenix_books, PhoenixBooks.Endpoint, server: true
57 | #
58 |
59 | # Finally import the config/prod.secret.exs
60 | # which should be versioned separately.
61 | import_config "prod.secret.exs"
62 |
--------------------------------------------------------------------------------
/performance/phoenix_books/config/test.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
3 | # We don't run a server during test. If one is required,
4 | # you can enable the server option below.
5 | config :phoenix_books, PhoenixBooks.Endpoint,
6 | http: [port: 4001],
7 | server: false
8 |
9 | # Print only warnings and errors during test
10 | config :logger, level: :warn
11 |
12 | # Configure your database
13 | config :phoenix_books, PhoenixBooks.Repo,
14 | adapter: Ecto.Adapters.Postgres,
15 | username: "postgres",
16 | password: "postgres",
17 | database: "phoenix_books_test",
18 | hostname: "localhost",
19 | pool: Ecto.Adapters.SQL.Sandbox
20 |
--------------------------------------------------------------------------------
/performance/phoenix_books/lib/phoenix_books.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks do
2 | use Application
3 |
4 | # See http://elixir-lang.org/docs/stable/elixir/Application.html
5 | # for more information on OTP Applications
6 | def start(_type, _args) do
7 | import Supervisor.Spec
8 |
9 | # Define workers and child supervisors to be supervised
10 | children = [
11 | # Start the Ecto repository
12 | supervisor(PhoenixBooks.Repo, []),
13 | # Start the endpoint when the application starts
14 | supervisor(PhoenixBooks.Endpoint, []),
15 | # Start your own worker by calling: PhoenixBooks.Worker.start_link(arg1, arg2, arg3)
16 | # worker(PhoenixBooks.Worker, [arg1, arg2, arg3]),
17 | ]
18 |
19 | # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
20 | # for other strategies and supported options
21 | opts = [strategy: :one_for_one, name: PhoenixBooks.Supervisor]
22 | Supervisor.start_link(children, opts)
23 | end
24 |
25 | # Tell Phoenix to update the endpoint configuration
26 | # whenever the application is updated.
27 | def config_change(changed, _new, removed) do
28 | PhoenixBooks.Endpoint.config_change(changed, removed)
29 | :ok
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/performance/phoenix_books/lib/phoenix_books/endpoint.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Endpoint do
2 | use Phoenix.Endpoint, otp_app: :phoenix_books
3 |
4 | socket "/socket", PhoenixBooks.UserSocket
5 |
6 | # Serve at "/" the static files from "priv/static" directory.
7 | #
8 | # You should set gzip to true if you are running phoenix.digest
9 | # when deploying your static files in production.
10 | plug Plug.Static,
11 | at: "/", from: :phoenix_books, gzip: false,
12 | only: ~w(css fonts images js favicon.ico robots.txt)
13 |
14 | # Code reloading can be explicitly enabled under the
15 | # :code_reloader configuration of your endpoint.
16 | if code_reloading? do
17 | socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
18 | plug Phoenix.LiveReloader
19 | plug Phoenix.CodeReloader
20 | end
21 |
22 | plug Plug.RequestId
23 | plug Plug.Logger
24 |
25 | plug Plug.Parsers,
26 | parsers: [:urlencoded, :multipart, :json],
27 | pass: ["*/*"],
28 | json_decoder: Poison
29 |
30 | plug Plug.MethodOverride
31 | plug Plug.Head
32 |
33 | # The session will be stored in the cookie and signed,
34 | # this means its contents can be read but not tampered with.
35 | # Set :encryption_salt if you would also like to encrypt it.
36 | plug Plug.Session,
37 | store: :cookie,
38 | key: "_phoenix_books_key",
39 | signing_salt: "Arcd+3Cq"
40 |
41 | plug PhoenixBooks.Router
42 | end
43 |
--------------------------------------------------------------------------------
/performance/phoenix_books/lib/phoenix_books/repo.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Repo do
2 | use Ecto.Repo, otp_app: :phoenix_books
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/mix.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Mixfile do
2 | use Mix.Project
3 |
4 | def project do
5 | [app: :phoenix_books,
6 | version: "0.0.1",
7 | elixir: "~> 1.2",
8 | elixirc_paths: elixirc_paths(Mix.env),
9 | compilers: [:phoenix, :gettext] ++ Mix.compilers,
10 | build_embedded: Mix.env == :prod,
11 | start_permanent: Mix.env == :prod,
12 | aliases: aliases(),
13 | deps: deps()]
14 | end
15 |
16 | # Configuration for the OTP application.
17 | #
18 | # Type `mix help compile.app` for more information.
19 | def application do
20 | [mod: {PhoenixBooks, []},
21 | applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
22 | :phoenix_ecto, :postgrex]]
23 | end
24 |
25 | # Specifies which paths to compile per environment.
26 | defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
27 | defp elixirc_paths(_), do: ["lib", "web"]
28 |
29 | # Specifies your project dependencies.
30 | #
31 | # Type `mix help deps` for examples and options.
32 | defp deps do
33 | [{:phoenix, "~> 1.2.1"},
34 | {:phoenix_pubsub, "~> 1.0"},
35 | {:phoenix_ecto, "~> 3.0"},
36 | {:postgrex, ">= 0.0.0"},
37 | {:phoenix_html, "~> 2.6"},
38 | {:phoenix_live_reload, "~> 1.0", only: :dev},
39 | {:gettext, "~> 0.11"},
40 | {:cowboy, "~> 1.0"}]
41 | end
42 |
43 | # Aliases are shortcuts or tasks specific to the current project.
44 | # For example, to create, migrate and run the seeds file at once:
45 | #
46 | # $ mix ecto.setup
47 | #
48 | # See the documentation for `Mix` for more info on aliases.
49 | defp aliases do
50 | ["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
51 | "ecto.reset": ["ecto.drop", "ecto.setup"],
52 | "test": ["ecto.create --quiet", "ecto.migrate", "test"]]
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/performance/phoenix_books/mix.lock:
--------------------------------------------------------------------------------
1 | %{"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
2 | "cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
3 | "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
4 | "db_connection": {:hex, :db_connection, "1.1.0", "b2b88db6d7d12f99997b584d09fad98e560b817a20dab6a526830e339f54cdb3", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
5 | "decimal": {:hex, :decimal, "1.3.1", "157b3cedb2bfcb5359372a7766dd7a41091ad34578296e951f58a946fcab49c6", [:mix], []},
6 | "ecto": {:hex, :ecto, "2.1.3", "ffb24e150b519a4c0e4c84f9eabc8587199389bc499195d5d1a93cd3b2d9a045", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
7 | "fs": {:hex, :fs, "2.12.0", "ad631efacc9a5683c8eaa1b274e24fa64a1b8eb30747e9595b93bec7e492e25e", [:rebar3], []},
8 | "gettext": {:hex, :gettext, "0.13.0", "daafbddc5cda12738bb93b01d84105fe75b916a302f1c50ab9fb066b95ec9db4", [:mix], []},
9 | "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []},
10 | "phoenix": {:hex, :phoenix, "1.2.1", "6dc592249ab73c67575769765b66ad164ad25d83defa3492dc6ae269bd2a68ab", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}]},
11 | "phoenix_ecto": {:hex, :phoenix_ecto, "3.2.1", "6cf11d590c61977f50fcb98ad8a10ee90ba8670a82cbf5eaf49cfaee2e95e8b7", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]},
12 | "phoenix_html": {:hex, :phoenix_html, "2.9.2", "371160b30cf4e10443b015efce6f03e1f19aae98ff6487620477b13a5b2ef660", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
13 | "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.7", "167ab0942e88d1d4a597996cf7dd8d2b014cc14d3f9472b58858cde8dd9ac2e4", [:mix], [{:fs, "~> 2.12.0", [hex: :fs, optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, optional: false]}]},
14 | "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.1", "c10ddf6237007c804bf2b8f3c4d5b99009b42eca3a0dfac04ea2d8001186056a", [:mix], []},
15 | "plug": {:hex, :plug, "1.3.0", "6e2b01afc5db3fd011ca4a16efd9cb424528c157c30a44a0186bcc92c7b2e8f3", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
16 | "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
17 | "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
18 | "postgrex": {:hex, :postgrex, "0.13.0", "e101ab47d0725955c5c8830ae8812412992e02e4bd9db09e17abb0a5d82d09c7", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]},
19 | "ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []}}
20 |
--------------------------------------------------------------------------------
/performance/phoenix_books/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "repository": {},
3 | "license": "MIT",
4 | "scripts": {
5 | "deploy": "brunch build --production",
6 | "watch": "brunch watch --stdin"
7 | },
8 | "dependencies": {
9 | "phoenix": "file:deps/phoenix",
10 | "phoenix_html": "file:deps/phoenix_html"
11 | },
12 | "devDependencies": {
13 | "babel-brunch": "~6.0.0",
14 | "brunch": "2.7.4",
15 | "clean-css-brunch": "~2.0.0",
16 | "css-brunch": "~2.0.0",
17 | "javascript-brunch": "~2.0.0",
18 | "uglify-js-brunch": "~2.0.1"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/performance/phoenix_books/priv/gettext/en/LC_MESSAGES/errors.po:
--------------------------------------------------------------------------------
1 | ## `msgid`s in this file come from POT (.pot) files.
2 | ##
3 | ## Do not add, change, or remove `msgid`s manually here as
4 | ## they're tied to the ones in the corresponding POT file
5 | ## (with the same domain).
6 | ##
7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge`
8 | ## to merge POT files into PO files.
9 | msgid ""
10 | msgstr ""
11 | "Language: en\n"
12 |
13 | ## From Ecto.Changeset.cast/4
14 | msgid "can't be blank"
15 | msgstr ""
16 |
17 | ## From Ecto.Changeset.unique_constraint/3
18 | msgid "has already been taken"
19 | msgstr ""
20 |
21 | ## From Ecto.Changeset.put_change/3
22 | msgid "is invalid"
23 | msgstr ""
24 |
25 | ## From Ecto.Changeset.validate_format/3
26 | msgid "has invalid format"
27 | msgstr ""
28 |
29 | ## From Ecto.Changeset.validate_subset/3
30 | msgid "has an invalid entry"
31 | msgstr ""
32 |
33 | ## From Ecto.Changeset.validate_exclusion/3
34 | msgid "is reserved"
35 | msgstr ""
36 |
37 | ## From Ecto.Changeset.validate_confirmation/3
38 | msgid "does not match confirmation"
39 | msgstr ""
40 |
41 | ## From Ecto.Changeset.no_assoc_constraint/3
42 | msgid "is still associated to this entry"
43 | msgstr ""
44 |
45 | msgid "are still associated to this entry"
46 | msgstr ""
47 |
48 | ## From Ecto.Changeset.validate_length/3
49 | msgid "should be %{count} character(s)"
50 | msgid_plural "should be %{count} character(s)"
51 | msgstr[0] ""
52 | msgstr[1] ""
53 |
54 | msgid "should have %{count} item(s)"
55 | msgid_plural "should have %{count} item(s)"
56 | msgstr[0] ""
57 | msgstr[1] ""
58 |
59 | msgid "should be at least %{count} character(s)"
60 | msgid_plural "should be at least %{count} character(s)"
61 | msgstr[0] ""
62 | msgstr[1] ""
63 |
64 | msgid "should have at least %{count} item(s)"
65 | msgid_plural "should have at least %{count} item(s)"
66 | msgstr[0] ""
67 | msgstr[1] ""
68 |
69 | msgid "should be at most %{count} character(s)"
70 | msgid_plural "should be at most %{count} character(s)"
71 | msgstr[0] ""
72 | msgstr[1] ""
73 |
74 | msgid "should have at most %{count} item(s)"
75 | msgid_plural "should have at most %{count} item(s)"
76 | msgstr[0] ""
77 | msgstr[1] ""
78 |
79 | ## From Ecto.Changeset.validate_number/3
80 | msgid "must be less than %{number}"
81 | msgstr ""
82 |
83 | msgid "must be greater than %{number}"
84 | msgstr ""
85 |
86 | msgid "must be less than or equal to %{number}"
87 | msgstr ""
88 |
89 | msgid "must be greater than or equal to %{number}"
90 | msgstr ""
91 |
92 | msgid "must be equal to %{number}"
93 | msgstr ""
94 |
--------------------------------------------------------------------------------
/performance/phoenix_books/priv/gettext/errors.pot:
--------------------------------------------------------------------------------
1 | ## This file is a PO Template file.
2 | ##
3 | ## `msgid`s here are often extracted from source code.
4 | ## Add new translations manually only if they're dynamic
5 | ## translations that can't be statically extracted.
6 | ##
7 | ## Run `mix gettext.extract` to bring this file up to
8 | ## date. Leave `msgstr`s empty as changing them here as no
9 | ## effect: edit them in PO (`.po`) files instead.
10 |
11 | ## From Ecto.Changeset.cast/4
12 | msgid "can't be blank"
13 | msgstr ""
14 |
15 | ## From Ecto.Changeset.unique_constraint/3
16 | msgid "has already been taken"
17 | msgstr ""
18 |
19 | ## From Ecto.Changeset.put_change/3
20 | msgid "is invalid"
21 | msgstr ""
22 |
23 | ## From Ecto.Changeset.validate_format/3
24 | msgid "has invalid format"
25 | msgstr ""
26 |
27 | ## From Ecto.Changeset.validate_subset/3
28 | msgid "has an invalid entry"
29 | msgstr ""
30 |
31 | ## From Ecto.Changeset.validate_exclusion/3
32 | msgid "is reserved"
33 | msgstr ""
34 |
35 | ## From Ecto.Changeset.validate_confirmation/3
36 | msgid "does not match confirmation"
37 | msgstr ""
38 |
39 | ## From Ecto.Changeset.no_assoc_constraint/3
40 | msgid "is still associated to this entry"
41 | msgstr ""
42 |
43 | msgid "are still associated to this entry"
44 | msgstr ""
45 |
46 | ## From Ecto.Changeset.validate_length/3
47 | msgid "should be %{count} character(s)"
48 | msgid_plural "should be %{count} character(s)"
49 | msgstr[0] ""
50 | msgstr[1] ""
51 |
52 | msgid "should have %{count} item(s)"
53 | msgid_plural "should have %{count} item(s)"
54 | msgstr[0] ""
55 | msgstr[1] ""
56 |
57 | msgid "should be at least %{count} character(s)"
58 | msgid_plural "should be at least %{count} character(s)"
59 | msgstr[0] ""
60 | msgstr[1] ""
61 |
62 | msgid "should have at least %{count} item(s)"
63 | msgid_plural "should have at least %{count} item(s)"
64 | msgstr[0] ""
65 | msgstr[1] ""
66 |
67 | msgid "should be at most %{count} character(s)"
68 | msgid_plural "should be at most %{count} character(s)"
69 | msgstr[0] ""
70 | msgstr[1] ""
71 |
72 | msgid "should have at most %{count} item(s)"
73 | msgid_plural "should have at most %{count} item(s)"
74 | msgstr[0] ""
75 | msgstr[1] ""
76 |
77 | ## From Ecto.Changeset.validate_number/3
78 | msgid "must be less than %{number}"
79 | msgstr ""
80 |
81 | msgid "must be greater than %{number}"
82 | msgstr ""
83 |
84 | msgid "must be less than or equal to %{number}"
85 | msgstr ""
86 |
87 | msgid "must be greater than or equal to %{number}"
88 | msgstr ""
89 |
90 | msgid "must be equal to %{number}"
91 | msgstr ""
92 |
--------------------------------------------------------------------------------
/performance/phoenix_books/priv/repo/migrations/20170125190255_create_book.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Repo.Migrations.CreateBook do
2 | use Ecto.Migration
3 |
4 | def change do
5 | create table(:books) do
6 | add :title, :string
7 | add :author, :string
8 |
9 | timestamps()
10 | end
11 |
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/performance/phoenix_books/priv/repo/seeds.exs:
--------------------------------------------------------------------------------
1 | # Script for populating the database. You can run it as:
2 | #
3 | # mix run priv/repo/seeds.exs
4 | #
5 | # Inside the script, you can read and write to any of your
6 | # repositories directly:
7 | #
8 | # PhoenixBooks.Repo.insert!(%PhoenixBooks.SomeModel{})
9 | #
10 | # We recommend using the bang functions (`insert!`, `update!`
11 | # and so on) as they will fail if something goes wrong.
12 |
13 | for _ <- 1..10 do
14 | PhoenixBooks.Repo.insert!(%PhoenixBooks.Book{title: "Ready Player One", author: "Ernest Cline"})
15 | PhoenixBooks.Repo.insert!(%PhoenixBooks.Book{title: "Rails for dummies", author: "Alex Kovshovik"})
16 | PhoenixBooks.Repo.insert!(%PhoenixBooks.Book{title: "Benefits mode easy", author: "Jim Scott"})
17 | end
18 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/controllers/book_controller_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.BookControllerTest do
2 | use PhoenixBooks.ConnCase
3 |
4 | alias PhoenixBooks.Book
5 | @valid_attrs %{author: "some content", title: "some content"}
6 | @invalid_attrs %{}
7 |
8 | test "lists all entries on index", %{conn: conn} do
9 | conn = get conn, book_path(conn, :index)
10 | assert html_response(conn, 200) =~ "Listing books"
11 | end
12 |
13 | test "renders form for new resources", %{conn: conn} do
14 | conn = get conn, book_path(conn, :new)
15 | assert html_response(conn, 200) =~ "New book"
16 | end
17 |
18 | test "creates resource and redirects when data is valid", %{conn: conn} do
19 | conn = post conn, book_path(conn, :create), book: @valid_attrs
20 | assert redirected_to(conn) == book_path(conn, :index)
21 | assert Repo.get_by(Book, @valid_attrs)
22 | end
23 |
24 | test "does not create resource and renders errors when data is invalid", %{conn: conn} do
25 | conn = post conn, book_path(conn, :create), book: @invalid_attrs
26 | assert html_response(conn, 200) =~ "New book"
27 | end
28 |
29 | test "shows chosen resource", %{conn: conn} do
30 | book = Repo.insert! %Book{}
31 | conn = get conn, book_path(conn, :show, book)
32 | assert html_response(conn, 200) =~ "Show book"
33 | end
34 |
35 | test "renders page not found when id is nonexistent", %{conn: conn} do
36 | assert_error_sent 404, fn ->
37 | get conn, book_path(conn, :show, -1)
38 | end
39 | end
40 |
41 | test "renders form for editing chosen resource", %{conn: conn} do
42 | book = Repo.insert! %Book{}
43 | conn = get conn, book_path(conn, :edit, book)
44 | assert html_response(conn, 200) =~ "Edit book"
45 | end
46 |
47 | test "updates chosen resource and redirects when data is valid", %{conn: conn} do
48 | book = Repo.insert! %Book{}
49 | conn = put conn, book_path(conn, :update, book), book: @valid_attrs
50 | assert redirected_to(conn) == book_path(conn, :show, book)
51 | assert Repo.get_by(Book, @valid_attrs)
52 | end
53 |
54 | test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
55 | book = Repo.insert! %Book{}
56 | conn = put conn, book_path(conn, :update, book), book: @invalid_attrs
57 | assert html_response(conn, 200) =~ "Edit book"
58 | end
59 |
60 | test "deletes chosen resource", %{conn: conn} do
61 | book = Repo.insert! %Book{}
62 | conn = delete conn, book_path(conn, :delete, book)
63 | assert redirected_to(conn) == book_path(conn, :index)
64 | refute Repo.get(Book, book.id)
65 | end
66 | end
67 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/controllers/page_controller_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.PageControllerTest do
2 | use PhoenixBooks.ConnCase
3 |
4 | test "GET /", %{conn: conn} do
5 | conn = get conn, "/"
6 | assert html_response(conn, 200) =~ "Welcome to Phoenix!"
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/models/book_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.BookTest do
2 | use PhoenixBooks.ModelCase
3 |
4 | alias PhoenixBooks.Book
5 |
6 | @valid_attrs %{author: "some content", title: "some content"}
7 | @invalid_attrs %{}
8 |
9 | test "changeset with valid attributes" do
10 | changeset = Book.changeset(%Book{}, @valid_attrs)
11 | assert changeset.valid?
12 | end
13 |
14 | test "changeset with invalid attributes" do
15 | changeset = Book.changeset(%Book{}, @invalid_attrs)
16 | refute changeset.valid?
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/support/channel_case.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ChannelCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | channel tests.
5 |
6 | Such tests rely on `Phoenix.ChannelTest` and also
7 | import other functionality to make it easier
8 | to build and query models.
9 |
10 | Finally, if the test case interacts with the database,
11 | it cannot be async. For this reason, every test runs
12 | inside a transaction which is reset at the beginning
13 | of the test unless the test case is marked as async.
14 | """
15 |
16 | use ExUnit.CaseTemplate
17 |
18 | using do
19 | quote do
20 | # Import conveniences for testing with channels
21 | use Phoenix.ChannelTest
22 |
23 | alias PhoenixBooks.Repo
24 | import Ecto
25 | import Ecto.Changeset
26 | import Ecto.Query
27 |
28 |
29 | # The default endpoint for testing
30 | @endpoint PhoenixBooks.Endpoint
31 | end
32 | end
33 |
34 | setup tags do
35 | :ok = Ecto.Adapters.SQL.Sandbox.checkout(PhoenixBooks.Repo)
36 |
37 | unless tags[:async] do
38 | Ecto.Adapters.SQL.Sandbox.mode(PhoenixBooks.Repo, {:shared, self()})
39 | end
40 |
41 | :ok
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/support/conn_case.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ConnCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | tests that require setting up a connection.
5 |
6 | Such tests rely on `Phoenix.ConnTest` and also
7 | import other functionality to make it easier
8 | to build and query models.
9 |
10 | Finally, if the test case interacts with the database,
11 | it cannot be async. For this reason, every test runs
12 | inside a transaction which is reset at the beginning
13 | of the test unless the test case is marked as async.
14 | """
15 |
16 | use ExUnit.CaseTemplate
17 |
18 | using do
19 | quote do
20 | # Import conveniences for testing with connections
21 | use Phoenix.ConnTest
22 |
23 | alias PhoenixBooks.Repo
24 | import Ecto
25 | import Ecto.Changeset
26 | import Ecto.Query
27 |
28 | import PhoenixBooks.Router.Helpers
29 |
30 | # The default endpoint for testing
31 | @endpoint PhoenixBooks.Endpoint
32 | end
33 | end
34 |
35 | setup tags do
36 | :ok = Ecto.Adapters.SQL.Sandbox.checkout(PhoenixBooks.Repo)
37 |
38 | unless tags[:async] do
39 | Ecto.Adapters.SQL.Sandbox.mode(PhoenixBooks.Repo, {:shared, self()})
40 | end
41 |
42 | {:ok, conn: Phoenix.ConnTest.build_conn()}
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/support/model_case.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ModelCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | model tests.
5 |
6 | You may define functions here to be used as helpers in
7 | your model tests. See `errors_on/2`'s definition as reference.
8 |
9 | Finally, if the test case interacts with the database,
10 | it cannot be async. For this reason, every test runs
11 | inside a transaction which is reset at the beginning
12 | of the test unless the test case is marked as async.
13 | """
14 |
15 | use ExUnit.CaseTemplate
16 |
17 | using do
18 | quote do
19 | alias PhoenixBooks.Repo
20 |
21 | import Ecto
22 | import Ecto.Changeset
23 | import Ecto.Query
24 | import PhoenixBooks.ModelCase
25 | end
26 | end
27 |
28 | setup tags do
29 | :ok = Ecto.Adapters.SQL.Sandbox.checkout(PhoenixBooks.Repo)
30 |
31 | unless tags[:async] do
32 | Ecto.Adapters.SQL.Sandbox.mode(PhoenixBooks.Repo, {:shared, self()})
33 | end
34 |
35 | :ok
36 | end
37 |
38 | @doc """
39 | Helper for returning list of errors in a struct when given certain data.
40 |
41 | ## Examples
42 |
43 | Given a User schema that lists `:name` as a required field and validates
44 | `:password` to be safe, it would return:
45 |
46 | iex> errors_on(%User{}, %{password: "password"})
47 | [password: "is unsafe", name: "is blank"]
48 |
49 | You could then write your assertion like:
50 |
51 | assert {:password, "is unsafe"} in errors_on(%User{}, %{password: "password"})
52 |
53 | You can also create the changeset manually and retrieve the errors
54 | field directly:
55 |
56 | iex> changeset = User.changeset(%User{}, password: "password")
57 | iex> {:password, "is unsafe"} in changeset.errors
58 | true
59 | """
60 | def errors_on(struct, data) do
61 | struct.__struct__.changeset(struct, data)
62 | |> Ecto.Changeset.traverse_errors(&PhoenixBooks.ErrorHelpers.translate_error/1)
63 | |> Enum.flat_map(fn {key, errors} -> for msg <- errors, do: {key, msg} end)
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/test_helper.exs:
--------------------------------------------------------------------------------
1 | ExUnit.start
2 |
3 | Ecto.Adapters.SQL.Sandbox.mode(PhoenixBooks.Repo, :manual)
4 |
5 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/views/error_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ErrorViewTest do
2 | use PhoenixBooks.ConnCase, async: true
3 |
4 | # Bring render/3 and render_to_string/3 for testing custom views
5 | import Phoenix.View
6 |
7 | test "renders 404.html" do
8 | assert render_to_string(PhoenixBooks.ErrorView, "404.html", []) ==
9 | "Page not found"
10 | end
11 |
12 | test "render 500.html" do
13 | assert render_to_string(PhoenixBooks.ErrorView, "500.html", []) ==
14 | "Internal server error"
15 | end
16 |
17 | test "render any other" do
18 | assert render_to_string(PhoenixBooks.ErrorView, "505.html", []) ==
19 | "Internal server error"
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/views/layout_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.LayoutViewTest do
2 | use PhoenixBooks.ConnCase, async: true
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/test/views/page_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.PageViewTest do
2 | use PhoenixBooks.ConnCase, async: true
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/channels/user_socket.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.UserSocket do
2 | use Phoenix.Socket
3 |
4 | ## Channels
5 | # channel "room:*", PhoenixBooks.RoomChannel
6 |
7 | ## Transports
8 | transport :websocket, Phoenix.Transports.WebSocket
9 | # transport :longpoll, Phoenix.Transports.LongPoll
10 |
11 | # Socket params are passed from the client and can
12 | # be used to verify and authenticate a user. After
13 | # verification, you can put default assigns into
14 | # the socket that will be set for all channels, ie
15 | #
16 | # {:ok, assign(socket, :user_id, verified_user_id)}
17 | #
18 | # To deny connection, return `:error`.
19 | #
20 | # See `Phoenix.Token` documentation for examples in
21 | # performing token verification on connect.
22 | def connect(_params, socket) do
23 | {:ok, socket}
24 | end
25 |
26 | # Socket id's are topics that allow you to identify all sockets for a given user:
27 | #
28 | # def id(socket), do: "users_socket:#{socket.assigns.user_id}"
29 | #
30 | # Would allow you to broadcast a "disconnect" event and terminate
31 | # all active sockets and channels for a given user:
32 | #
33 | # PhoenixBooks.Endpoint.broadcast("users_socket:#{user.id}", "disconnect", %{})
34 | #
35 | # Returning `nil` makes this socket anonymous.
36 | def id(_socket), do: nil
37 | end
38 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/controllers/book_controller.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.BookController do
2 | use PhoenixBooks.Web, :controller
3 |
4 | alias PhoenixBooks.Book
5 |
6 | def index(conn, _params) do
7 | books = Repo.all(Book)
8 | render(conn, "index.html", books: books)
9 | end
10 |
11 | def new(conn, _params) do
12 | changeset = Book.changeset(%Book{})
13 | render(conn, "new.html", changeset: changeset)
14 | end
15 |
16 | def create(conn, %{"book" => book_params}) do
17 | changeset = Book.changeset(%Book{}, book_params)
18 |
19 | case Repo.insert(changeset) do
20 | {:ok, _book} ->
21 | conn
22 | |> put_flash(:info, "Book created successfully.")
23 | |> redirect(to: book_path(conn, :index))
24 | {:error, changeset} ->
25 | render(conn, "new.html", changeset: changeset)
26 | end
27 | end
28 |
29 | def show(conn, %{"id" => id}) do
30 | book = Repo.get!(Book, id)
31 | render(conn, "show.html", book: book)
32 | end
33 |
34 | def edit(conn, %{"id" => id}) do
35 | book = Repo.get!(Book, id)
36 | changeset = Book.changeset(book)
37 | render(conn, "edit.html", book: book, changeset: changeset)
38 | end
39 |
40 | def update(conn, %{"id" => id, "book" => book_params}) do
41 | book = Repo.get!(Book, id)
42 | changeset = Book.changeset(book, book_params)
43 |
44 | case Repo.update(changeset) do
45 | {:ok, book} ->
46 | conn
47 | |> put_flash(:info, "Book updated successfully.")
48 | |> redirect(to: book_path(conn, :show, book))
49 | {:error, changeset} ->
50 | render(conn, "edit.html", book: book, changeset: changeset)
51 | end
52 | end
53 |
54 | def delete(conn, %{"id" => id}) do
55 | book = Repo.get!(Book, id)
56 |
57 | # Here we use delete! (with a bang) because we expect
58 | # it to always work (and if it does not, it will raise).
59 | Repo.delete!(book)
60 |
61 | conn
62 | |> put_flash(:info, "Book deleted successfully.")
63 | |> redirect(to: book_path(conn, :index))
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/controllers/page_controller.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.PageController do
2 | use PhoenixBooks.Web, :controller
3 |
4 | def index(conn, _params) do
5 | render conn, "index.html"
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/gettext.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Gettext do
2 | @moduledoc """
3 | A module providing Internationalization with a gettext-based API.
4 |
5 | By using [Gettext](https://hexdocs.pm/gettext),
6 | your module gains a set of macros for translations, for example:
7 |
8 | import PhoenixBooks.Gettext
9 |
10 | # Simple translation
11 | gettext "Here is the string to translate"
12 |
13 | # Plural translation
14 | ngettext "Here is the string to translate",
15 | "Here are the strings to translate",
16 | 3
17 |
18 | # Domain-based translation
19 | dgettext "errors", "Here is the error message to translate"
20 |
21 | See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
22 | """
23 | use Gettext, otp_app: :phoenix_books
24 | end
25 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/models/book.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Book do
2 | use PhoenixBooks.Web, :model
3 |
4 | schema "books" do
5 | field :title, :string
6 | field :author, :string
7 |
8 | timestamps()
9 | end
10 |
11 | @doc """
12 | Builds a changeset based on the `struct` and `params`.
13 | """
14 | def changeset(struct, params \\ %{}) do
15 | struct
16 | |> cast(params, [:title, :author])
17 | |> validate_required([:title, :author])
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/router.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Router do
2 | use PhoenixBooks.Web, :router
3 |
4 | pipeline :browser do
5 | plug :accepts, ["html"]
6 | plug :fetch_session
7 | plug :fetch_flash
8 | plug :protect_from_forgery
9 | plug :put_secure_browser_headers
10 | end
11 |
12 | pipeline :api do
13 | plug :accepts, ["json"]
14 | end
15 |
16 | scope "/", PhoenixBooks do
17 | pipe_through :browser # Use the default browser stack
18 | resources "/books", BookController
19 | get "/", PageController, :index
20 | end
21 |
22 | # Other scopes may use custom stacks.
23 | # scope "/api", PhoenixBooks do
24 | # pipe_through :api
25 | # end
26 | end
27 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/phoenix_books/web/static/assets/favicon.ico
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/assets/images/phoenix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/phoenix_books/web/static/assets/images/phoenix.png
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/assets/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/css/app.css:
--------------------------------------------------------------------------------
1 | /* This file is for your main application css. */
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/js/app.js:
--------------------------------------------------------------------------------
1 | // Brunch automatically concatenates all files in your
2 | // watched paths. Those paths can be configured at
3 | // config.paths.watched in "brunch-config.js".
4 | //
5 | // However, those files will only be executed if
6 | // explicitly imported. The only exception are files
7 | // in vendor, which are never wrapped in imports and
8 | // therefore are always executed.
9 |
10 | // Import dependencies
11 | //
12 | // If you no longer want to use a dependency, remember
13 | // to also remove its path from "config.paths.watched".
14 | import "phoenix_html"
15 |
16 | // Import local files
17 | //
18 | // Local files can be imported directly using relative
19 | // paths "./socket" or full ones "web/static/js/socket".
20 |
21 | // import socket from "./socket"
22 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/static/js/socket.js:
--------------------------------------------------------------------------------
1 | // NOTE: The contents of this file will only be executed if
2 | // you uncomment its entry in "web/static/js/app.js".
3 |
4 | // To use Phoenix channels, the first step is to import Socket
5 | // and connect at the socket path in "lib/my_app/endpoint.ex":
6 | import {Socket} from "phoenix"
7 |
8 | let socket = new Socket("/socket", {params: {token: window.userToken}})
9 |
10 | // When you connect, you'll often need to authenticate the client.
11 | // For example, imagine you have an authentication plug, `MyAuth`,
12 | // which authenticates the session and assigns a `:current_user`.
13 | // If the current user exists you can assign the user's token in
14 | // the connection for use in the layout.
15 | //
16 | // In your "web/router.ex":
17 | //
18 | // pipeline :browser do
19 | // ...
20 | // plug MyAuth
21 | // plug :put_user_token
22 | // end
23 | //
24 | // defp put_user_token(conn, _) do
25 | // if current_user = conn.assigns[:current_user] do
26 | // token = Phoenix.Token.sign(conn, "user socket", current_user.id)
27 | // assign(conn, :user_token, token)
28 | // else
29 | // conn
30 | // end
31 | // end
32 | //
33 | // Now you need to pass this token to JavaScript. You can do so
34 | // inside a script tag in "web/templates/layout/app.html.eex":
35 | //
36 | //
37 | //
38 | // You will need to verify the user token in the "connect/2" function
39 | // in "web/channels/user_socket.ex":
40 | //
41 | // def connect(%{"token" => token}, socket) do
42 | // # max_age: 1209600 is equivalent to two weeks in seconds
43 | // case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
44 | // {:ok, user_id} ->
45 | // {:ok, assign(socket, :user, user_id)}
46 | // {:error, reason} ->
47 | // :error
48 | // end
49 | // end
50 | //
51 | // Finally, pass the token on connect as below. Or remove it
52 | // from connect if you don't care about authentication.
53 |
54 | socket.connect()
55 |
56 | // Now that you are connected, you can join channels with a topic:
57 | let channel = socket.channel("topic:subtopic", {})
58 | channel.join()
59 | .receive("ok", resp => { console.log("Joined successfully", resp) })
60 | .receive("error", resp => { console.log("Unable to join", resp) })
61 |
62 | export default socket
63 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/book/edit.html.eex:
--------------------------------------------------------------------------------
1 | Edit book
2 |
3 | <%= render "form.html", changeset: @changeset,
4 | action: book_path(@conn, :update, @book) %>
5 |
6 | <%= link "Back", to: book_path(@conn, :index) %>
7 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/book/form.html.eex:
--------------------------------------------------------------------------------
1 | <%= form_for @changeset, @action, fn f -> %>
2 | <%= if @changeset.action do %>
3 |
4 |
Oops, something went wrong! Please check the errors below.
5 |
6 | <% end %>
7 |
8 |
9 | <%= label f, :title, class: "control-label" %>
10 | <%= text_input f, :title, class: "form-control" %>
11 | <%= error_tag f, :title %>
12 |
13 |
14 |
15 | <%= label f, :author, class: "control-label" %>
16 | <%= text_input f, :author, class: "form-control" %>
17 | <%= error_tag f, :author %>
18 |
19 |
20 |
21 | <%= submit "Submit", class: "btn btn-primary" %>
22 |
23 | <% end %>
24 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/book/index.html.eex:
--------------------------------------------------------------------------------
1 | Listing books
2 |
3 |
4 |
5 |
6 | Title
7 | Author
8 |
9 |
10 |
11 |
12 |
13 | <%= for book <- @books do %>
14 |
15 | <%= book.title %>
16 | <%= book.author %>
17 |
18 |
19 | <%= link "Show", to: book_path(@conn, :show, book), class: "btn btn-default btn-xs" %>
20 | <%= link "Edit", to: book_path(@conn, :edit, book), class: "btn btn-default btn-xs" %>
21 | <%= link "Delete", to: book_path(@conn, :delete, book), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>
22 |
23 |
24 | <% end %>
25 |
26 |
27 |
28 | <%= link "New book", to: book_path(@conn, :new) %>
29 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/book/new.html.eex:
--------------------------------------------------------------------------------
1 | New book
2 |
3 | <%= render "form.html", changeset: @changeset,
4 | action: book_path(@conn, :create) %>
5 |
6 | <%= link "Back", to: book_path(@conn, :index) %>
7 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/book/show.html.eex:
--------------------------------------------------------------------------------
1 | Show book
2 |
3 |
4 |
5 |
6 | Title:
7 | <%= @book.title %>
8 |
9 |
10 |
11 | Author:
12 | <%= @book.author %>
13 |
14 |
15 |
16 |
17 | <%= link "Edit", to: book_path(@conn, :edit, @book) %>
18 | <%= link "Back", to: book_path(@conn, :index) %>
19 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/layout/app.html.eex:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Hello PhoenixBooks!
11 | ">
12 |
13 |
14 |
15 |
16 |
24 |
25 |
<%= get_flash(@conn, :info) %>
26 |
<%= get_flash(@conn, :error) %>
27 |
28 |
29 | <%= render @view_module, @view_template, assigns %>
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/templates/page/index.html.eex:
--------------------------------------------------------------------------------
1 |
2 |
<%= gettext "Welcome to %{name}", name: "Phoenix!" %>
3 |
A productive web framework that does not compromise speed and maintainability.
4 |
5 |
6 |
37 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/views/book_view.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.BookView do
2 | use PhoenixBooks.Web, :view
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/views/error_helpers.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ErrorHelpers do
2 | @moduledoc """
3 | Conveniences for translating and building error messages.
4 | """
5 |
6 | use Phoenix.HTML
7 |
8 | @doc """
9 | Generates tag for inlined form input errors.
10 | """
11 | def error_tag(form, field) do
12 | if error = form.errors[field] do
13 | content_tag :span, translate_error(error), class: "help-block"
14 | end
15 | end
16 |
17 | @doc """
18 | Translates an error message using gettext.
19 | """
20 | def translate_error({msg, opts}) do
21 | # Because error messages were defined within Ecto, we must
22 | # call the Gettext module passing our Gettext backend. We
23 | # also use the "errors" domain as translations are placed
24 | # in the errors.po file.
25 | # Ecto will pass the :count keyword if the error message is
26 | # meant to be pluralized.
27 | # On your own code and templates, depending on whether you
28 | # need the message to be pluralized or not, this could be
29 | # written simply as:
30 | #
31 | # dngettext "errors", "1 file", "%{count} files", count
32 | # dgettext "errors", "is invalid"
33 | #
34 | if count = opts[:count] do
35 | Gettext.dngettext(PhoenixBooks.Gettext, "errors", msg, msg, count, opts)
36 | else
37 | Gettext.dgettext(PhoenixBooks.Gettext, "errors", msg, opts)
38 | end
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/views/error_view.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.ErrorView do
2 | use PhoenixBooks.Web, :view
3 |
4 | def render("404.html", _assigns) do
5 | "Page not found"
6 | end
7 |
8 | def render("500.html", _assigns) do
9 | "Internal server error"
10 | end
11 |
12 | # In case no render clause matches or no
13 | # template is found, let's render it as 500
14 | def template_not_found(_template, assigns) do
15 | render "500.html", assigns
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/views/layout_view.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.LayoutView do
2 | use PhoenixBooks.Web, :view
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/views/page_view.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.PageView do
2 | use PhoenixBooks.Web, :view
3 | end
4 |
--------------------------------------------------------------------------------
/performance/phoenix_books/web/web.ex:
--------------------------------------------------------------------------------
1 | defmodule PhoenixBooks.Web do
2 | @moduledoc """
3 | A module that keeps using definitions for controllers,
4 | views and so on.
5 |
6 | This can be used in your application as:
7 |
8 | use PhoenixBooks.Web, :controller
9 | use PhoenixBooks.Web, :view
10 |
11 | The definitions below will be executed for every view,
12 | controller, etc, so keep them short and clean, focused
13 | on imports, uses and aliases.
14 |
15 | Do NOT define functions inside the quoted expressions
16 | below.
17 | """
18 |
19 | def model do
20 | quote do
21 | use Ecto.Schema
22 |
23 | import Ecto
24 | import Ecto.Changeset
25 | import Ecto.Query
26 | end
27 | end
28 |
29 | def controller do
30 | quote do
31 | use Phoenix.Controller
32 |
33 | alias PhoenixBooks.Repo
34 | import Ecto
35 | import Ecto.Query
36 |
37 | import PhoenixBooks.Router.Helpers
38 | import PhoenixBooks.Gettext
39 | end
40 | end
41 |
42 | def view do
43 | quote do
44 | use Phoenix.View, root: "web/templates"
45 |
46 | # Import convenience functions from controllers
47 | import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
48 |
49 | # Use all HTML functionality (forms, tags, etc)
50 | use Phoenix.HTML
51 |
52 | import PhoenixBooks.Router.Helpers
53 | import PhoenixBooks.ErrorHelpers
54 | import PhoenixBooks.Gettext
55 | end
56 | end
57 |
58 | def router do
59 | quote do
60 | use Phoenix.Router
61 | end
62 | end
63 |
64 | def channel do
65 | quote do
66 | use Phoenix.Channel
67 |
68 | alias PhoenixBooks.Repo
69 | import Ecto
70 | import Ecto.Query
71 | import PhoenixBooks.Gettext
72 | end
73 | end
74 |
75 | @doc """
76 | When used, dispatch to the appropriate controller/view/etc.
77 | """
78 | defmacro __using__(which) when is_atom(which) do
79 | apply(__MODULE__, which, [])
80 | end
81 | end
82 |
--------------------------------------------------------------------------------
/performance/rails_books/.gitignore:
--------------------------------------------------------------------------------
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 the default SQLite database.
11 | /db/*.sqlite3
12 | /db/*.sqlite3-journal
13 |
14 | # Ignore all logfiles and tempfiles.
15 | /log/*
16 | /tmp/*
17 | !/log/.keep
18 | !/tmp/.keep
19 |
20 | # Ignore Byebug command history file.
21 | .byebug_history
22 |
--------------------------------------------------------------------------------
/performance/rails_books/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Rails
2 | --
3 | Configuração de Produção Básica sem tuning
4 |
5 | Dependency
6 | > cd rails_books
7 | > bundle
8 |
9 | Seed
10 | > RAILS_ENV=production rails db:drop db:create db:migrate db:seed
11 |
12 | Starting
13 | > rails s -e production
14 |
--------------------------------------------------------------------------------
/performance/rails_books/Gemfile:
--------------------------------------------------------------------------------
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 |
9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10 | gem 'rails', '~> 5.0.1'
11 | # Use sqlite3 as the database for Active Record
12 | gem 'pg'
13 | # Use Puma as the app server
14 | gem 'puma', '~> 3.0'
15 | # Use SCSS for stylesheets
16 | gem 'sass-rails', '~> 5.0'
17 | # Use Uglifier as compressor for JavaScript assets
18 | gem 'uglifier', '>= 1.3.0'
19 | # Use CoffeeScript for .coffee assets and views
20 | gem 'coffee-rails', '~> 4.2'
21 | # See https://github.com/rails/execjs#readme for more supported runtimes
22 | # gem 'therubyracer', platforms: :ruby
23 |
24 | # Use jquery as the JavaScript library
25 | gem 'jquery-rails'
26 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
27 | gem 'turbolinks', '~> 5'
28 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
29 | gem 'jbuilder', '~> 2.5'
30 | # Use Redis adapter to run Action Cable in production
31 | # gem 'redis', '~> 3.0'
32 | # Use ActiveModel has_secure_password
33 | # gem 'bcrypt', '~> 3.1.7'
34 |
35 | # Use Capistrano for deployment
36 | # gem 'capistrano-rails', group: :development
37 |
38 | group :development, :test do
39 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console
40 | gem 'byebug', platform: :mri
41 | end
42 |
43 | group :development do
44 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
45 | gem 'web-console', '>= 3.3.0'
46 | gem 'listen', '~> 3.0.5'
47 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
48 | gem 'spring'
49 | gem 'spring-watcher-listen', '~> 2.0.0'
50 | end
51 |
52 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
53 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
54 |
--------------------------------------------------------------------------------
/performance/rails_books/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (5.0.1)
5 | actionpack (= 5.0.1)
6 | nio4r (~> 1.2)
7 | websocket-driver (~> 0.6.1)
8 | actionmailer (5.0.1)
9 | actionpack (= 5.0.1)
10 | actionview (= 5.0.1)
11 | activejob (= 5.0.1)
12 | mail (~> 2.5, >= 2.5.4)
13 | rails-dom-testing (~> 2.0)
14 | actionpack (5.0.1)
15 | actionview (= 5.0.1)
16 | activesupport (= 5.0.1)
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.0.1)
22 | activesupport (= 5.0.1)
23 | builder (~> 3.1)
24 | erubis (~> 2.7.0)
25 | rails-dom-testing (~> 2.0)
26 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
27 | activejob (5.0.1)
28 | activesupport (= 5.0.1)
29 | globalid (>= 0.3.6)
30 | activemodel (5.0.1)
31 | activesupport (= 5.0.1)
32 | activerecord (5.0.1)
33 | activemodel (= 5.0.1)
34 | activesupport (= 5.0.1)
35 | arel (~> 7.0)
36 | activesupport (5.0.1)
37 | concurrent-ruby (~> 1.0, >= 1.0.2)
38 | i18n (~> 0.7)
39 | minitest (~> 5.1)
40 | tzinfo (~> 1.1)
41 | arel (7.1.4)
42 | builder (3.2.3)
43 | byebug (9.0.6)
44 | coffee-rails (4.2.1)
45 | coffee-script (>= 2.2.0)
46 | railties (>= 4.0.0, < 5.2.x)
47 | coffee-script (2.4.1)
48 | coffee-script-source
49 | execjs
50 | coffee-script-source (1.12.2)
51 | concurrent-ruby (1.0.4)
52 | debug_inspector (0.0.2)
53 | erubis (2.7.0)
54 | execjs (2.7.0)
55 | ffi (1.9.17)
56 | globalid (0.3.7)
57 | activesupport (>= 4.1.0)
58 | i18n (0.7.0)
59 | jbuilder (2.6.1)
60 | activesupport (>= 3.0.0, < 5.1)
61 | multi_json (~> 1.2)
62 | jquery-rails (4.2.2)
63 | rails-dom-testing (>= 1, < 3)
64 | railties (>= 4.2.0)
65 | thor (>= 0.14, < 2.0)
66 | listen (3.0.8)
67 | rb-fsevent (~> 0.9, >= 0.9.4)
68 | rb-inotify (~> 0.9, >= 0.9.7)
69 | loofah (2.0.3)
70 | nokogiri (>= 1.5.9)
71 | mail (2.6.4)
72 | mime-types (>= 1.16, < 4)
73 | method_source (0.8.2)
74 | mime-types (3.1)
75 | mime-types-data (~> 3.2015)
76 | mime-types-data (3.2016.0521)
77 | mini_portile2 (2.1.0)
78 | minitest (5.10.1)
79 | multi_json (1.12.1)
80 | nio4r (1.2.1)
81 | nokogiri (1.7.0.1)
82 | mini_portile2 (~> 2.1.0)
83 | pg (0.19.0)
84 | puma (3.6.2)
85 | rack (2.0.1)
86 | rack-test (0.6.3)
87 | rack (>= 1.0)
88 | rails (5.0.1)
89 | actioncable (= 5.0.1)
90 | actionmailer (= 5.0.1)
91 | actionpack (= 5.0.1)
92 | actionview (= 5.0.1)
93 | activejob (= 5.0.1)
94 | activemodel (= 5.0.1)
95 | activerecord (= 5.0.1)
96 | activesupport (= 5.0.1)
97 | bundler (>= 1.3.0, < 2.0)
98 | railties (= 5.0.1)
99 | sprockets-rails (>= 2.0.0)
100 | rails-dom-testing (2.0.2)
101 | activesupport (>= 4.2.0, < 6.0)
102 | nokogiri (~> 1.6)
103 | rails-html-sanitizer (1.0.3)
104 | loofah (~> 2.0)
105 | railties (5.0.1)
106 | actionpack (= 5.0.1)
107 | activesupport (= 5.0.1)
108 | method_source
109 | rake (>= 0.8.7)
110 | thor (>= 0.18.1, < 2.0)
111 | rake (12.0.0)
112 | rb-fsevent (0.9.8)
113 | rb-inotify (0.9.7)
114 | ffi (>= 0.5.0)
115 | sass (3.4.23)
116 | sass-rails (5.0.6)
117 | railties (>= 4.0.0, < 6)
118 | sass (~> 3.1)
119 | sprockets (>= 2.8, < 4.0)
120 | sprockets-rails (>= 2.0, < 4.0)
121 | tilt (>= 1.1, < 3)
122 | spring (2.0.1)
123 | activesupport (>= 4.2)
124 | spring-watcher-listen (2.0.1)
125 | listen (>= 2.7, < 4.0)
126 | spring (>= 1.2, < 3.0)
127 | sprockets (3.7.1)
128 | concurrent-ruby (~> 1.0)
129 | rack (> 1, < 3)
130 | sprockets-rails (3.2.0)
131 | actionpack (>= 4.0)
132 | activesupport (>= 4.0)
133 | sprockets (>= 3.0.0)
134 | thor (0.19.4)
135 | thread_safe (0.3.5)
136 | tilt (2.0.5)
137 | turbolinks (5.0.1)
138 | turbolinks-source (~> 5)
139 | turbolinks-source (5.0.0)
140 | tzinfo (1.2.2)
141 | thread_safe (~> 0.1)
142 | uglifier (3.0.4)
143 | execjs (>= 0.3.0, < 3)
144 | web-console (3.4.0)
145 | actionview (>= 5.0)
146 | activemodel (>= 5.0)
147 | debug_inspector
148 | railties (>= 5.0)
149 | websocket-driver (0.6.5)
150 | websocket-extensions (>= 0.1.0)
151 | websocket-extensions (0.1.2)
152 |
153 | PLATFORMS
154 | ruby
155 |
156 | DEPENDENCIES
157 | byebug
158 | coffee-rails (~> 4.2)
159 | jbuilder (~> 2.5)
160 | jquery-rails
161 | listen (~> 3.0.5)
162 | pg
163 | puma (~> 3.0)
164 | rails (~> 5.0.1)
165 | sass-rails (~> 5.0)
166 | spring
167 | spring-watcher-listen (~> 2.0.0)
168 | turbolinks (~> 5)
169 | tzinfo-data
170 | uglifier (>= 1.3.0)
171 | web-console (>= 3.3.0)
172 |
173 | BUNDLED WITH
174 | 1.14.3
175 |
--------------------------------------------------------------------------------
/performance/rails_books/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/README.md
--------------------------------------------------------------------------------
/performance/rails_books/Rakefile:
--------------------------------------------------------------------------------
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
7 |
--------------------------------------------------------------------------------
/performance/rails_books/ab-report-development.txt:
--------------------------------------------------------------------------------
1 | rails s
2 | ab -n 1000 -c 50 http://localhost:3000/books
3 | Benchmarking localhost (be patient)
4 | Completed 100 requests
5 | Completed 200 requests
6 | Completed 300 requests
7 | Completed 400 requests
8 | Completed 500 requests
9 | Completed 600 requests
10 | Completed 700 requests
11 | Completed 800 requests
12 | Completed 900 requests
13 | Completed 1000 requests
14 | Finished 1000 requests
15 |
16 |
17 | Server Software:
18 | Server Hostname: localhost
19 | Server Port: 3000
20 |
21 | Document Path: /books
22 | Document Length: 3005 bytes
23 |
24 | Concurrency Level: 50
25 | Time taken for tests: 33.028 seconds
26 | Complete requests: 1000
27 | Failed requests: 2
28 | (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
29 | Non-2xx responses: 2
30 | Total transferred: 4029163 bytes
31 | HTML transferred: 3367931 bytes
32 | Requests per second: 30.28 [#/sec] (mean)
33 | Time per request: 1651.409 [ms] (mean)
34 | Time per request: 33.028 [ms] (mean, across all concurrent requests)
35 | Transfer rate: 119.13 [Kbytes/sec] received
36 |
37 | Connection Times (ms)
38 | min mean[+/-sd] median max
39 | Connect: 0 0 0.2 0 1
40 | Processing: 648 1614 135.4 1610 2338
41 | Waiting: 648 1614 135.3 1610 2327
42 | Total: 649 1614 135.3 1610 2338
43 |
44 | puma -t 8:32 -w 3
45 | ab -n 1000 -c 50 http://localhost:3000/books
46 | Benchmarking localhost (be patient)
47 | Completed 100 requests
48 | Completed 200 requests
49 | Completed 300 requests
50 | Completed 400 requests
51 | Completed 500 requests
52 | Completed 600 requests
53 | Completed 700 requests
54 | Completed 800 requests
55 | Completed 900 requests
56 | Completed 1000 requests
57 | Finished 1000 requests
58 |
59 |
60 | Server Software:
61 | Server Hostname: localhost
62 | Server Port: 3000
63 |
64 | Document Path: /books
65 | Document Length: 3005 bytes
66 |
67 | Concurrency Level: 50
68 | Time taken for tests: 21.661 seconds
69 | Complete requests: 1000
70 | Failed requests: 26
71 | (Connect: 0, Receive: 0, Length: 26, Exceptions: 0)
72 | Non-2xx responses: 26
73 | Total transferred: 6330869 bytes
74 | HTML transferred: 5678872 bytes
75 | Requests per second: 46.17 [#/sec] (mean)
76 | Time per request: 1083.057 [ms] (mean)
77 | Time per request: 21.661 [ms] (mean, across all concurrent requests)
78 | Transfer rate: 285.42 [Kbytes/sec] received
79 |
80 | Connection Times (ms)
81 | min mean[+/-sd] median max
82 | Connect: 0 0 0.3 0 2
83 | Processing: 21 1068 2034.4 420 11997
84 | Waiting: 21 1067 2034.2 420 11996
85 | Total: 21 1068 2034.5 420 11998
86 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../javascripts .js
3 | //= link_directory ../stylesheets .css
4 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/app/assets/images/.keep
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require turbolinks
16 | //= require_tree .
17 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/javascripts/books.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/javascripts/cable.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the rails generate channel command.
3 | //
4 | //= require action_cable
5 | //= require_self
6 | //= require_tree ./channels
7 |
8 | (function() {
9 | this.App || (this.App = {});
10 |
11 | App.cable = ActionCable.createConsumer();
12 |
13 | }).call(this);
14 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/javascripts/channels/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/app/assets/javascripts/channels/.keep
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/stylesheets/books.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the books controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/performance/rails_books/app/assets/stylesheets/scaffolds.scss:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #fff;
3 | color: #333;
4 | font-family: verdana, arial, helvetica, sans-serif;
5 | font-size: 13px;
6 | line-height: 18px;
7 | margin: 33px;
8 | }
9 |
10 | p, ol, ul, td {
11 | font-family: verdana, arial, helvetica, sans-serif;
12 | font-size: 13px;
13 | line-height: 18px;
14 | margin: 33px;
15 | }
16 |
17 | pre {
18 | background-color: #eee;
19 | padding: 10px;
20 | font-size: 11px;
21 | }
22 |
23 | a {
24 | color: #000;
25 |
26 | &:visited {
27 | color: #666;
28 | }
29 |
30 | &:hover {
31 | color: #fff;
32 | background-color: #000;
33 | }
34 | }
35 |
36 | th {
37 | padding-bottom: 5px;
38 | }
39 |
40 | td {
41 | padding-bottom: 7px;
42 | padding-left: 5px;
43 | padding-right: 5px;
44 | }
45 |
46 | div {
47 | &.field, &.actions {
48 | margin-bottom: 10px;
49 | }
50 | }
51 |
52 | #notice {
53 | color: green;
54 | }
55 |
56 | .field_with_errors {
57 | padding: 2px;
58 | background-color: red;
59 | display: table;
60 | }
61 |
62 | #error_explanation {
63 | width: 450px;
64 | border: 2px solid red;
65 | padding: 7px;
66 | padding-bottom: 0;
67 | margin-bottom: 20px;
68 | background-color: #f0f0f0;
69 |
70 | h2 {
71 | text-align: left;
72 | font-weight: bold;
73 | padding: 5px 5px 5px 15px;
74 | font-size: 12px;
75 | margin: -7px;
76 | margin-bottom: 0;
77 | background-color: #c00;
78 | color: #fff;
79 | }
80 |
81 | ul li {
82 | font-size: 12px;
83 | list-style: square;
84 | }
85 | }
86 |
87 | label {
88 | display: block;
89 | }
90 |
--------------------------------------------------------------------------------
/performance/rails_books/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/performance/rails_books/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/performance/rails_books/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery with: :exception
3 | end
4 |
--------------------------------------------------------------------------------
/performance/rails_books/app/controllers/books_controller.rb:
--------------------------------------------------------------------------------
1 | class BooksController < ApplicationController
2 | before_action :set_book, only: [:show, :edit, :update, :destroy]
3 |
4 | # GET /books
5 | # GET /books.json
6 | def index
7 | @books = Book.all
8 | end
9 |
10 | # GET /books/1
11 | # GET /books/1.json
12 | def show
13 | end
14 |
15 | # GET /books/new
16 | def new
17 | @book = Book.new
18 | end
19 |
20 | # GET /books/1/edit
21 | def edit
22 | end
23 |
24 | # POST /books
25 | # POST /books.json
26 | def create
27 | @book = Book.new(book_params)
28 |
29 | respond_to do |format|
30 | if @book.save
31 | format.html { redirect_to @book, notice: 'Book was successfully created.' }
32 | format.json { render :show, status: :created, location: @book }
33 | else
34 | format.html { render :new }
35 | format.json { render json: @book.errors, status: :unprocessable_entity }
36 | end
37 | end
38 | end
39 |
40 | # PATCH/PUT /books/1
41 | # PATCH/PUT /books/1.json
42 | def update
43 | respond_to do |format|
44 | if @book.update(book_params)
45 | format.html { redirect_to @book, notice: 'Book was successfully updated.' }
46 | format.json { render :show, status: :ok, location: @book }
47 | else
48 | format.html { render :edit }
49 | format.json { render json: @book.errors, status: :unprocessable_entity }
50 | end
51 | end
52 | end
53 |
54 | # DELETE /books/1
55 | # DELETE /books/1.json
56 | def destroy
57 | @book.destroy
58 | respond_to do |format|
59 | format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
60 | format.json { head :no_content }
61 | end
62 | end
63 |
64 | private
65 | # Use callbacks to share common setup or constraints between actions.
66 | def set_book
67 | @book = Book.find(params[:id])
68 | end
69 |
70 | # Never trust parameters from the scary internet, only allow the white list through.
71 | def book_params
72 | params.require(:book).permit(:title, :author)
73 | end
74 | end
75 |
--------------------------------------------------------------------------------
/performance/rails_books/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/performance/rails_books/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/performance/rails_books/app/helpers/books_helper.rb:
--------------------------------------------------------------------------------
1 | module BooksHelper
2 | end
3 |
--------------------------------------------------------------------------------
/performance/rails_books/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | end
3 |
--------------------------------------------------------------------------------
/performance/rails_books/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: 'from@example.com'
3 | layout 'mailer'
4 | end
5 |
--------------------------------------------------------------------------------
/performance/rails_books/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | self.abstract_class = true
3 | end
4 |
--------------------------------------------------------------------------------
/performance/rails_books/app/models/book.rb:
--------------------------------------------------------------------------------
1 | class Book < ApplicationRecord
2 | end
3 |
--------------------------------------------------------------------------------
/performance/rails_books/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/app/models/concerns/.keep
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/_book.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! book, :id, :title, :author, :created_at, :updated_at
2 | json.url book_url(book, format: :json)
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_for(book) do |f| %>
2 | <% if book.errors.any? %>
3 |
4 |
<%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:
5 |
6 |
7 | <% book.errors.full_messages.each do |message| %>
8 | <%= message %>
9 | <% end %>
10 |
11 |
12 | <% end %>
13 |
14 |
15 | <%= f.label :title %>
16 | <%= f.text_field :title %>
17 |
18 |
19 |
20 | <%= f.label :author %>
21 | <%= f.text_field :author %>
22 |
23 |
24 |
25 | <%= f.submit %>
26 |
27 | <% end %>
28 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/edit.html.erb:
--------------------------------------------------------------------------------
1 | Editing Book
2 |
3 | <%= render 'form', book: @book %>
4 |
5 | <%= link_to 'Show', @book %> |
6 | <%= link_to 'Back', books_path %>
7 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/index.html.erb:
--------------------------------------------------------------------------------
1 | <%= notice %>
2 |
3 | Books
4 |
5 |
6 |
7 |
8 | Title
9 | Author
10 |
11 |
12 |
13 |
14 |
15 | <% @books.each do |book| %>
16 |
17 | <%= book.title %>
18 | <%= book.author %>
19 | <%= link_to 'Show', book %>
20 | <%= link_to 'Edit', edit_book_path(book) %>
21 | <%= link_to 'Destroy', book, method: :delete, data: { confirm: 'Are you sure?' } %>
22 |
23 | <% end %>
24 |
25 |
26 |
27 |
28 |
29 | <%= link_to 'New Book', new_book_path %>
30 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.array! @books, partial: 'books/book', as: :book
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/new.html.erb:
--------------------------------------------------------------------------------
1 | New Book
2 |
3 | <%= render 'form', book: @book %>
4 |
5 | <%= link_to 'Back', books_path %>
6 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= notice %>
2 |
3 |
4 | Title:
5 | <%= @book.title %>
6 |
7 |
8 |
9 | Author:
10 | <%= @book.author %>
11 |
12 |
13 | <%= link_to 'Edit', edit_book_path(@book) %> |
14 | <%= link_to 'Back', books_path %>
15 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/books/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! "books/book", book: @book
--------------------------------------------------------------------------------
/performance/rails_books/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RailsBooks
5 | <%= csrf_meta_tags %>
6 |
7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/performance/rails_books/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # puts "\n== Copying sample files =="
22 | # unless File.exist?('config/database.yml')
23 | # cp 'config/database.yml.sample', 'config/database.yml'
24 | # end
25 |
26 | puts "\n== Preparing database =="
27 | system! 'bin/rails db:setup'
28 |
29 | puts "\n== Removing old logs and tempfiles =="
30 | system! 'bin/rails log:clear tmp:clear'
31 |
32 | puts "\n== Restarting application server =="
33 | system! 'bin/rails restart'
34 | end
35 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/performance/rails_books/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/performance/rails_books/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative 'config/environment'
4 |
5 | run Rails.application
6 |
--------------------------------------------------------------------------------
/performance/rails_books/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module RailsBooks
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/performance/rails_books/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/performance/rails_books/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 |
--------------------------------------------------------------------------------
/performance/rails_books/config/database.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: postgresql
3 | encoding: unicode
4 | database: rails_books_development
5 | host: localhost
6 | pool: 10
7 | username: "postgres"
8 | password: "postgres"
9 |
10 | production:
11 | adapter: postgresql
12 | encoding: unicode
13 | database: rails_books_production
14 | host: localhost
15 | pool: 10
16 | username: "postgres"
17 | password: "postgres"
18 |
19 | test:
20 | adapter: postgresql
21 | encoding: unicode
22 | database: rails_books_test
23 | host: localhost
24 | pool: 10
25 | username: "postgres"
26 | password: "postgres"
27 |
--------------------------------------------------------------------------------
/performance/rails_books/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/performance/rails_books/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports.
13 | config.consider_all_requests_local = true
14 |
15 | # Enable/disable caching. By default caching is disabled.
16 | if Rails.root.join('tmp/caching-dev.txt').exist?
17 | config.action_controller.perform_caching = true
18 |
19 | config.cache_store = :memory_store
20 | config.public_file_server.headers = {
21 | 'Cache-Control' => 'public, max-age=172800'
22 | }
23 | else
24 | config.action_controller.perform_caching = false
25 |
26 | config.cache_store = :null_store
27 | end
28 |
29 | # Don't care if the mailer can't send.
30 | config.action_mailer.raise_delivery_errors = false
31 |
32 | config.action_mailer.perform_caching = false
33 |
34 | # Print deprecation notices to the Rails logger.
35 | config.active_support.deprecation = :log
36 |
37 | # Raise an error on page load if there are pending migrations.
38 | config.active_record.migration_error = :page_load
39 |
40 | # Debug mode disables concatenation and preprocessing of assets.
41 | # This option may cause significant delays in view rendering with a large
42 | # number of complex assets.
43 | config.assets.debug = true
44 |
45 | # Suppress logger output for asset requests.
46 | config.assets.quiet = true
47 |
48 | # Raises error for missing translations
49 | # config.action_view.raise_on_missing_translations = true
50 |
51 | # Use an evented file watcher to asynchronously detect changes in source code,
52 | # routes, locales, etc. This feature depends on the listen gem.
53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54 | end
55 |
--------------------------------------------------------------------------------
/performance/rails_books/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Disable serving static files from the `/public` folder by default since
18 | # Apache or NGINX already handles this.
19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20 |
21 | # Compress JavaScripts and CSS.
22 | config.assets.js_compressor = :uglifier
23 | # config.assets.css_compressor = :sass
24 |
25 | # Do not fallback to assets pipeline if a precompiled asset is missed.
26 | config.assets.compile = false
27 |
28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29 |
30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31 | # config.action_controller.asset_host = 'http://assets.example.com'
32 |
33 | # Specifies the header that your server uses for sending files.
34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36 |
37 | # Mount Action Cable outside main process or domain
38 | # config.action_cable.mount_path = nil
39 | # config.action_cable.url = 'wss://example.com/cable'
40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Use the lowest log level to ensure availability of diagnostic information
46 | # when problems arise.
47 | config.log_level = :debug
48 |
49 | # Prepend all log lines with the following tags.
50 | config.log_tags = [ :request_id ]
51 |
52 | # Use a different cache store in production.
53 | # config.cache_store = :mem_cache_store
54 |
55 | # Use a real queuing backend for Active Job (and separate queues per environment)
56 | # config.active_job.queue_adapter = :resque
57 | # config.active_job.queue_name_prefix = "rails_books_#{Rails.env}"
58 | config.action_mailer.perform_caching = false
59 |
60 | # Ignore bad email addresses and do not raise email delivery errors.
61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62 | # config.action_mailer.raise_delivery_errors = false
63 |
64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65 | # the I18n.default_locale when a translation cannot be found).
66 | config.i18n.fallbacks = true
67 |
68 | # Send deprecation notices to registered listeners.
69 | config.active_support.deprecation = :notify
70 |
71 | # Use default logging formatter so that PID and timestamp are not suppressed.
72 | config.log_formatter = ::Logger::Formatter.new
73 |
74 | # Use a different logger for distributed setups.
75 | # require 'syslog/logger'
76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77 |
78 | if ENV["RAILS_LOG_TO_STDOUT"].present?
79 | logger = ActiveSupport::Logger.new(STDOUT)
80 | logger.formatter = config.log_formatter
81 | config.logger = ActiveSupport::TaggedLogging.new(logger)
82 | end
83 |
84 | # Do not dump schema after migrations.
85 | config.active_record.dump_schema_after_migration = false
86 | end
87 |
--------------------------------------------------------------------------------
/performance/rails_books/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => 'public, max-age=3600'
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/new_framework_defaults.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.0 upgrade.
4 | #
5 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
6 |
7 | # Enable per-form CSRF tokens. Previous versions had false.
8 | Rails.application.config.action_controller.per_form_csrf_tokens = true
9 |
10 | # Enable origin-checking CSRF mitigation. Previous versions had false.
11 | Rails.application.config.action_controller.forgery_protection_origin_check = true
12 |
13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14 | # Previous versions had false.
15 | ActiveSupport.to_time_preserves_timezone = true
16 |
17 | # Require `belongs_to` associations by default. Previous versions had false.
18 | Rails.application.config.active_record.belongs_to_required_by_default = true
19 |
20 | # Do not halt callback chains when a callback returns false. Previous versions had true.
21 | ActiveSupport.halt_callback_chains_on_return_false = false
22 |
23 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
24 | Rails.application.config.ssl_options = { hsts: { subdomains: true } }
25 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_rails_books_session'
4 |
--------------------------------------------------------------------------------
/performance/rails_books/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/performance/rails_books/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/performance/rails_books/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | resources :books
3 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
4 | end
5 |
--------------------------------------------------------------------------------
/performance/rails_books/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 70581bbef094f3bfa3a0b0b0c820bea4c18f54285024a9c8e2d0de46967fbe0e4ba968e922a97961ea626a97bdbdaf9e1a26e1d235cd5f105d1f347583f1926e
15 |
16 | test:
17 | secret_key_base: 06b26940f50980b50e1749afe98660d5d10b0558bb373d87031ab0636250a3927f2726a191906a7e6513f0a74c8fbd4d1ae5b0c8d0d7e8f1df5223dcf0bd11b6
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: 70581bbef094f3bfa3a0b0b0c820bea4c18f54285024a9c8e2d0de46967fbe0e4ba968e922a97961ea626a97bdbdaf9e1a26e1d235cd5f105d1f347583f1926e
23 |
--------------------------------------------------------------------------------
/performance/rails_books/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ).each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/performance/rails_books/db/migrate/20170125190032_create_books.rb:
--------------------------------------------------------------------------------
1 | class CreateBooks < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :books do |t|
4 | t.string :title
5 | t.string :author
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/performance/rails_books/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20170125190032) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "books", force: :cascade do |t|
19 | t.string "title"
20 | t.string "author"
21 | t.datetime "created_at", null: false
22 | t.datetime "updated_at", null: false
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/performance/rails_books/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
9 | 10.times do
10 | Book.create(title: "Ready Player One", author: "Ernest Cline")
11 | Book.create(title: "Rails for dummies", author: "Alex Kovshovik")
12 | Book.create(title: "Benefits mode easy", author: "Jim Scott")
13 | end
14 |
--------------------------------------------------------------------------------
/performance/rails_books/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/lib/assets/.keep
--------------------------------------------------------------------------------
/performance/rails_books/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/lib/tasks/.keep
--------------------------------------------------------------------------------
/performance/rails_books/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/log/.keep
--------------------------------------------------------------------------------
/performance/rails_books/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/performance/rails_books/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/performance/rails_books/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/performance/rails_books/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/public/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/performance/rails_books/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/performance/rails_books/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/public/favicon.ico
--------------------------------------------------------------------------------
/performance/rails_books/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/performance/rails_books/test/controllers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/controllers/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/controllers/books_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BooksControllerTest < ActionDispatch::IntegrationTest
4 | setup do
5 | @book = books(:one)
6 | end
7 |
8 | test "should get index" do
9 | get books_url
10 | assert_response :success
11 | end
12 |
13 | test "should get new" do
14 | get new_book_url
15 | assert_response :success
16 | end
17 |
18 | test "should create book" do
19 | assert_difference('Book.count') do
20 | post books_url, params: { book: { author: @book.author, title: @book.title } }
21 | end
22 |
23 | assert_redirected_to book_url(Book.last)
24 | end
25 |
26 | test "should show book" do
27 | get book_url(@book)
28 | assert_response :success
29 | end
30 |
31 | test "should get edit" do
32 | get edit_book_url(@book)
33 | assert_response :success
34 | end
35 |
36 | test "should update book" do
37 | patch book_url(@book), params: { book: { author: @book.author, title: @book.title } }
38 | assert_redirected_to book_url(@book)
39 | end
40 |
41 | test "should destroy book" do
42 | assert_difference('Book.count', -1) do
43 | delete book_url(@book)
44 | end
45 |
46 | assert_redirected_to books_url
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/performance/rails_books/test/fixtures/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/fixtures/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/fixtures/books.yml:
--------------------------------------------------------------------------------
1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2 |
3 | one:
4 | title: MyString
5 | author: MyString
6 |
7 | two:
8 | title: MyString
9 | author: MyString
10 |
--------------------------------------------------------------------------------
/performance/rails_books/test/fixtures/files/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/fixtures/files/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/helpers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/helpers/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/integration/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/integration/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/mailers/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/test/models/.keep
--------------------------------------------------------------------------------
/performance/rails_books/test/models/book_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BookTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/performance/rails_books/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV['RAILS_ENV'] ||= 'test'
2 | require File.expand_path('../../config/environment', __FILE__)
3 | require 'rails/test_help'
4 |
5 | class ActiveSupport::TestCase
6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7 | fixtures :all
8 |
9 | # Add more helper methods to be used by all tests here...
10 | end
11 |
--------------------------------------------------------------------------------
/performance/rails_books/tmp/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/tmp/.keep
--------------------------------------------------------------------------------
/performance/rails_books/vendor/assets/javascripts/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/vendor/assets/javascripts/.keep
--------------------------------------------------------------------------------
/performance/rails_books/vendor/assets/stylesheets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/performance/rails_books/vendor/assets/stylesheets/.keep
--------------------------------------------------------------------------------
/produtividade/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marcodotcastro/study-rails-vs-phoenix-vs-laravel/575db0c5040f0f45e70618fd396e754fd68185dc/produtividade/.gitkeep
--------------------------------------------------------------------------------