From 7409257702c8aa4e9703cab5b51d5a79d20f4b47 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 4 Mar 2015 23:14:43 +0100 Subject: [PATCH] Replaced HTML benchmark fixtures. The new fixture is the HTML of a person article which contains a few HTML entities. --- benchmark/benchmark_helper.rb | 2 +- benchmark/fixtures/gist.html | 2363 ------------------------- benchmark/fixtures/with_entities.html | 216 +++ 3 files changed, 217 insertions(+), 2364 deletions(-) delete mode 100644 benchmark/fixtures/gist.html create mode 100644 benchmark/fixtures/with_entities.html diff --git a/benchmark/benchmark_helper.rb b/benchmark/benchmark_helper.rb index 2bf70f6..cf8a5d9 100644 --- a/benchmark/benchmark_helper.rb +++ b/benchmark/benchmark_helper.rb @@ -28,7 +28,7 @@ end # @return [String] # def read_html - return File.read(File.expand_path('../fixtures/gist.html', __FILE__)) + return File.read(File.expand_path('../fixtures/with_entities.html', __FILE__)) end ## diff --git a/benchmark/fixtures/gist.html b/benchmark/fixtures/gist.html deleted file mode 100644 index 7b51929..0000000 --- a/benchmark/fixtures/gist.html +++ /dev/null @@ -1,2363 +0,0 @@ - - - - - - - Gists - - - - - - - - - - - - - - - - - -
- - - - -
-
- -
-
-
-

Gist is a simple way to share snippets and pastes with others. All gists are Git repositories, so they are automatically versioned, forkable and usable from Git.

-
-
-
- -
-
- - -
-
-
- -
- -
-
-
- -
-
-
- - -
- -
- - - - language: - Text - - -
- -
-
- Select a Language - -
- -
-
- -
-
- -
-
- -
- -
Text
-
- -
- -
ActionScript
-
-
- -
C
-
-
- -
C#
-
-
- -
C++
-
-
- -
Clojure
-
-
- -
CoffeeScript
-
-
- -
Common Lisp
-
-
- -
CSS
-
-
- -
Diff
-
-
- -
Emacs Lisp
-
-
- -
Erlang
-
-
- -
Haskell
-
-
- -
HTML
-
-
- -
Java
-
-
- -
JavaScript
-
-
- -
Lua
-
-
- -
Objective-C
-
-
- -
Perl
-
-
- -
PHP
-
-
- -
Python
-
-
- -
Ruby
-
-
- -
Scala
-
-
- -
Scheme
-
-
- -
SQL
-
- -
- -
ABAP
-
-
- -
Ada
-
-
- -
Agda
-
-
- -
ANTLR
-
-
- -
ApacheConf
-
-
- -
Apex
-
-
- -
AppleScript
-
-
- -
Arc
-
-
- -
Arduino
-
-
- -
AsciiDoc
-
-
- -
ASP
-
-
- -
Assembly
-
-
- -
Augeas
-
-
- -
AutoHotkey
-
-
- -
AutoIt
-
-
- -
Awk
-
-
- -
Batchfile
-
-
- -
Befunge
-
-
- -
BlitzBasic
-
-
- -
BlitzMax
-
-
- -
Bluespec
-
-
- -
Boo
-
-
- -
Brainfuck
-
-
- -
Brightscript
-
-
- -
Bro
-
-
- -
C-ObjDump
-
-
- -
C2hs Haskell
-
-
- -
Ceylon
-
-
- -
ChucK
-
-
- -
Clean
-
-
- -
CLIPS
-
-
- -
CMake
-
-
- -
COBOL
-
-
- -
ColdFusion
-
-
- -
Coq
-
-
- -
Cpp-ObjDump
-
-
- -
Creole
-
-
- -
Crystal
-
-
- -
Cucumber
-
-
- -
Cuda
-
-
- -
Cython
-
-
- -
D
-
-
- -
D-ObjDump
-
-
- -
Darcs Patch
-
-
- -
Dart
-
-
- -
DCPU-16 ASM
-
-
- -
DM
-
-
- -
DOT
-
-
- -
Dylan
-
-
- -
eC
-
-
- -
Ecere Projects
-
-
- -
ECL
-
-
- -
edn
-
-
- -
Eiffel
-
-
- -
Elixir
-
-
- -
Elm
-
-
- -
F#
-
-
- -
Factor
-
-
- -
Fancy
-
-
- -
Fantom
-
-
- -
fish
-
-
- -
Forth
-
-
- -
FORTRAN
-
-
- -
GAS
-
-
- -
Genshi
-
-
- -
Gentoo Ebuild
-
-
- -
Gentoo Eclass
-
-
- -
Gettext Catalog
-
-
- -
GLSL
-
-
- -
Glyph
-
-
- -
Go
-
-
- -
Gosu
-
-
- -
Groff
-
-
- -
Groovy
-
-
- -
Groovy Server Pages
-
-
- -
Haml
-
-
- -
Handlebars
-
-
- -
Harbour
-
-
- -
Haxe
-
-
- -
HTML+Django
-
-
- -
HTML+ERB
-
-
- -
HTML+PHP
-
-
- -
HTTP
-
-
- -
Hy
-
-
- -
IDL
-
-
- -
Idris
-
-
- -
INI
-
-
- -
Inno Setup
-
-
- -
Io
-
-
- -
Ioke
-
-
- -
IRC log
-
-
- -
J
-
-
- -
Jade
-
-
- -
Java Server Pages
-
-
- -
JSON
-
-
- -
JSON5
-
-
- -
Julia
-
-
- -
Kotlin
-
-
- -
KRL
-
-
- -
Lasso
-
-
- -
Less
-
-
- -
LFE
-
-
- -
LilyPond
-
-
- -
Literate Agda
-
-
- -
Literate CoffeeScript
-
-
- -
Literate Haskell
-
-
- -
LiveScript
-
-
- -
LLVM
-
-
- -
Logos
-
-
- -
Logtalk
-
-
- -
M
-
-
- -
Makefile
-
-
- -
Mako
-
-
- -
Markdown
-
-
- -
Matlab
-
-
- -
Max
-
-
- -
MediaWiki
-
-
- -
MiniD
-
-
- -
Mirah
-
-
- -
Monkey
-
-
- -
Moocode
-
-
- -
MoonScript
-
-
- -
mupad
-
-
- -
Myghty
-
-
- -
Nemerle
-
-
- -
nesC
-
-
- -
NetLogo
-
-
- -
Nginx
-
-
- -
Nimrod
-
-
- -
NSIS
-
-
- -
Nu
-
-
- -
NumPy
-
-
- -
ObjDump
-
-
- -
Objective-J
-
-
- -
OCaml
-
-
- -
Omgrofl
-
-
- -
ooc
-
-
- -
Opa
-
-
- -
OpenCL
-
-
- -
OpenEdge ABL
-
-
- -
Org
-
-
- -
Oxygene
-
-
- -
Parrot
-
-
- -
Parrot Assembly
-
-
- -
Parrot Internal Representation
-
-
- -
Pascal
-
-
- -
PAWN
-
-
- -
Perl6
-
-
- -
Pike
-
-
- -
Pod
-
-
- -
PogoScript
-
-
- -
PostScript
-
-
- -
PowerShell
-
-
- -
Processing
-
-
- -
Prolog
-
-
- -
Protocol Buffer
-
-
- -
Puppet
-
-
- -
Pure Data
-
-
- -
Python traceback
-
-
- -
QML
-
-
- -
R
-
-
- -
Racket
-
-
- -
Ragel in Ruby Host
-
-
- -
Raw token data
-
-
- -
RDoc
-
-
- -
REALbasic
-
-
- -
Rebol
-
-
- -
Redcode
-
-
- -
reStructuredText
-
-
- -
RHTML
-
-
- -
RMarkdown
-
-
- -
RobotFramework
-
-
- -
Rouge
-
-
- -
Rust
-
-
- -
Sage
-
-
- -
Sass
-
-
- -
Scaml
-
-
- -
Scilab
-
-
- -
SCSS
-
-
- -
Self
-
-
- -
Shell
-
-
- -
Slash
-
-
- -
Smalltalk
-
-
- -
Smarty
-
-
- -
Squirrel
-
-
- -
Standard ML
-
-
- -
Stylus
-
-
- -
SuperCollider
-
-
- -
Tcl
-
-
- -
Tcsh
-
-
- -
Tea
-
-
- -
TeX
-
-
- -
Textile
-
-
- -
TOML
-
-
- -
Turing
-
-
- -
Twig
-
-
- -
TXL
-
-
- -
TypeScript
-
-
- -
Unified Parallel C
-
-
- -
UnrealScript
-
-
- -
Vala
-
-
- -
Verilog
-
-
- -
VHDL
-
-
- -
VimL
-
-
- -
Visual Basic
-
-
- -
Volt
-
-
- -
wisp
-
-
- -
xBase
-
-
- -
XC
-
-
- -
XML
-
-
- -
XProc
-
-
- -
XQuery
-
-
- -
XS
-
-
- -
XSLT
-
-
- -
Xtend
-
-
- -
YAML
-
-
- -
Nothing to show
-
- -
-
-
- - -
-
- -
- -
- - - - indent mode: - Spaces - - -
-
-
- Select Indentation Mode - -
- -
-
-
- -
Spaces
-
- -
- -
Tabs
-
-
-
-
-
- -
- -
- - - - indent size: - 2 - - -
-
-
- Select Indentation Size - -
- -
-
-
- -
2
-
- -
- -
4
-
- -
- -
8
-
-
-
-
-
- -
- -
- -
-
-
Binary file not shown.
-
-
- -
-
-
- -
-
- - -
- -
- -
- -
-
- -

Drop one or more files here to prefill your gist!

-
-
- - -
- - -
-
-
-
- -
-
- -

Drop one or more files here to prefill your gist!

-
-
- -
-
- -
-
-
- -
-
- - Something went wrong with that request. Please try again. - -
-
- - - - - - diff --git a/benchmark/fixtures/with_entities.html b/benchmark/fixtures/with_entities.html new file mode 100644 index 0000000..38ae2b8 --- /dev/null +++ b/benchmark/fixtures/with_entities.html @@ -0,0 +1,216 @@ + + + + + + + + + + + + + +Debugging With Pry + + + +
+ +
+ +
+
+
+

Debugging With Pry

+

+Published on: +

+
+ +

Pry is a REPL (Read Eval Print Loop) that was written as a better alternative +to IRB. It comes with syntax highlighting, code indentation that actually works +and several other features that make it easier to debug code. I stumbled upon +Pry when looking for an alternative to both IRB and the way I was debugging my +code (placing puts all over the place, I think it’s called “Puts Driven +Development”).

+ +

Pry tries to do a lot of things and I was actually quite surprised how well it +does that. It might not stick to the Unix idea of only doing a single thing +(and doing that very well) but it makes my life (and the lifes of others) so +much easier that it’s easy to forget.

+ +

Pry is primarily meant to be used as a REPL. There are a lot of things that +make Pry so much more pleasant to use than IRB. One of the things almost any +Ruby programmer will notice when using IRB is that its indentation support is a +bit clunky. Indenting itself works fine most of the time but it fails to +un-indent code properly as illustrated in the code snippet below (pasted +directly from an IRB session):

+ +
ruby-1.9.3-p0 :001 > class User
+ruby-1.9.3-p0 :002?>   def greet
+ruby-1.9.3-p0 :003?>     puts "Hello world"
+ruby-1.9.3-p0 :004?>     end
+ruby-1.9.3-p0 :005?>   end
+ +

Luckily Pry handles this just fine, whether you’re trying to indent a class or +a hash containing an array containing a proc and so on. Pry does this by +resetting the terminal output every time a new line is entered. The downside of +this approach is that it only works on terminals that understand ANSI escape +codes. In Pry the above example works like it should do:

+ +
[1] pry(main)> class User
+[1] pry(main)*   def greet
+[1] pry(main)*     puts "Hello world"
+[1] pry(main)*   end
+[1] pry(main)* end
+ +

Besides indentation Pry does a lot more. A feature that I think is very cool is +the ability to show documentation and source code of methods right in your REPL +(sadly this feature doesn’t work with classes or modules at the time of +writing). This means that you no longer have to use the ri command to +search documentation for methods. You also don’t need to install the RDoc +documentation as Pry pulls it directly from the source code. Showing the source +code of a method or its documentation can be done by using the show-method +and show-doc command. For example, invoking show-method pry in a Pry +session would give you the following output:

+ +
[1] pry(main)> show-method pry
+
+From: /path/trimmed/for/readability/lib/pry/core_extensions.rb @ line 19:
+Number of lines: 3
+Owner: Object
+Visibility: public
+
+def pry(target=self)
+  Pry.start(target)
+end
+ +

Calling show-doc pry would instead show the following:

+ +
[2] pry(main)> show-doc pry
+
+From: /path/trimmed/for/readability/lib/pry/core_extensions.rb @ line 19:
+Number of lines: 17
+Owner: Object
+Visibility: public
+Signature: pry(target=?)
+
+Start a Pry REPL.
+This method differs from Pry.start in that it does not
+support an options hash. Also, when no parameter is provided, the Pry
+session will start on the implied receiver rather than on
+top-level (as in the case of Pry.start).
+It has two forms of invocation. In the first form no parameter
+should be provided and it will start a pry session on the
+receiver. In the second form it should be invoked without an
+explicit receiver and one parameter; this will start a Pry
+session on the parameter.
+param [Object, Binding] target The receiver of the Pry session.
+example First form
+  "dummy".pry
+example Second form
+   pry "dummy"
+example Start a Pry session on current self (whatever that is)
+  pry
+ +

You can also run these commands for code that was written in C. This requires +you to install the gem pry-doc (gem install pry-doc). Do note that this +only works for core C code, currently Pry does not support this for third party +extensions.

+ +

Another very cool feature is that Pry can be used as a debugging tool for your +code without having to manually jump into a session. By loading Pry, which can +be done by writing require "pry" or by using the option -r pry when +invoking Ruby you gain access to everything Pry has to offer. The most useful +tool is binding.pry. This method starts a Pry session and pauses the +script.

+ +

Lets say you have the following script and want to see the values of the +variables:

+ +
language = 'Ruby'
+number   = 10
+
+# Do something awesome with the above variables.
+ +

The typical approach would be to insert a puts statement above the comment +followed by an exit statement. Pry in a way can do a similar thing, it just +makes it a lot more awesome. If you modify the script as following you can +truly debug your code like a boss:

+ +
language = 'Ruby'
+number   = 10
+
+binding.pry
+
+# Do something awesome with the above variables.
+ +

If you now run the script by calling ruby -r pry file.rb you get a fancy +Pry session:

+ +
[yorickpeterse@Wifi-Ninja in ~]$ ruby -r pry file.rb
+
+From: file.rb @ line 4 in Object#N/A:
+
+     1: language = 'Ruby'
+     2: number   = 10
+     3:
+ =>  4: binding.pry
+     5:
+     6: # Do something awesome with the above variables.
+[1] pry(main)>
+ +

A nice thing about starting Pry this way is that it starts in the context of +the call to binding.pry meaning you get access to data such as the local +variables. These can be displayed by calling ls or by simply typing their +name.

+ +
[yorickpeterse@Wifi-Ninja in ~]$ ruby -r pry file.rb
+
+From: file.rb @ line 4 in Object#N/A:
+
+     1: language = 'Ruby'
+     2: number   = 10
+     3:
+ =>  4: binding.pry
+     5:
+     6: # Do something awesome with the above variables.
+[1] pry(main)> ls
+self methods: include  private  public  to_s
+locals: _  _dir_  _ex_  _file_  _in_  _out_  _pry_  language  number
+[2] pry(main)> number
+=> 10
+[3] pry(main)>
+ +

Moving out of the “breakpoint” (or moving to the next one if you have multiple +ones defined) can be done by hitting ^D (Ctrl+D usually).

+ +

Besides the features mentioned in this article Pry has several more. For +example, long output is piped to Less. This can be quite useful if you’re +trying to display a big hash using pp. The full list of features can be +found on the Pry website as well as by invoking the help +command inside a Pry session. If you’re in need of help or have any suggestions +you can join the IRC channel #pry on the Freenode network (irc.freenode.net). +The source code of Pry is hosted on Github.

+ + +
+
+ +