SlideShare ist ein Scribd-Unternehmen logo
1 von 56
RubyKaigi 2007 Session



C                      Ruby
    An Example of Ruby Program Faster Than C




                  makoto kuwata
           http://www.kuwata-lab.com


           copyright(c) 2007 kuwata-lab.com all rights reserved.
…



copyright(c) 2007 kuwata-lab.com all rights reserved.
2007
         Script Languages in 2007




       copyright(c) 2007 kuwata-lab.com all rights reserved.
PS3
         Break Away from PS3 Syndrome




‣ PS3/PSP …
  •

‣ Wii/DS …
  •


           copyright(c) 2007 kuwata-lab.com all rights reserved.
Script Languages can't be Center Player


‣                                                                 Java
    • Java
    •                                                          ≠


‣
    •
    •
              copyright(c) 2007 kuwata-lab.com all rights reserved.
Problems and Truth about Script Languages




✓

✓

✓



           copyright(c) 2007 kuwata-lab.com all rights reserved.
About This Presentation




copyright(c) 2007 kuwata-lab.com all rights reserved.
Point




                      ≠
Language Speed ≠ Application Speed




      copyright(c) 2007 kuwata-lab.com all rights reserved.
Overview



‣   :

‣   : C                       Ruby

‣   : eRuby

‣   :                    C
        ≦                              Ruby
        ≪≪≪≪≪                                                     C


          copyright(c) 2007 kuwata-lab.com all rights reserved.
Conclusion



‣

    •

‣
    •


        copyright(c) 2007 kuwata-lab.com all rights reserved.
eRuby
     Introduction to eRuby




 copyright(c) 2007 kuwata-lab.com all rights reserved.
eRuby
                       What is eRuby?


‣   eRuby (Embedded Ruby) …
                                           Ruby                      (   )


‣   eRuby                  …
     Ruby
            Ruby
       • eruby … C
       • ERB … pure Ruby Ruby1.8
             copyright(c) 2007 kuwata-lab.com all rights reserved.
Example


<table>
 <tbody>
<% for item in list %>
  <tr>
    <td><%= item %></td>
  </tr>
<% end %>
 </tbody>            <% ... ... %>
<table>              <%= ... ... %>



      copyright(c) 2007 kuwata-lab.com all rights reserved.
C         eruby
        Ruby Script Translated by eruby


print "<table>n"
print " <tbody>n"
 for item in list ; print "n"
print " <tr>n"
print " <td>"; print(( item )); print "</td>n"
print " </tr>n"
 end ; print "n"
print " </tbody>n"                print
print "<table>n"                  1


          copyright(c) 2007 kuwata-lab.com all rights reserved.
ERB
              Ruby Script Translated by ERB

_erbout = ""; _erbout.concat "<table>n"
_erbout.concat " <tbody>n"
 for item in list ; _erbout.concat "n"
_erbout.concat " <tr>n"
_erbout.concat " <td>"; _erbout.concat(( item ).to_s);
_erbout.concat "</td>n"
_erbout.concat " </tr>n"
 end ; _erbout.concat "n"
_erbout.concat " </tbody>n"
_erbout.concat "<table>n"
_erbout                                  1
               copyright(c) 2007 kuwata-lab.com all rights reserved.
Output Example

<table>
 <tbody>
  <tr>
    <td>AAA</td>
  </tr>
  <tr>
    <td>BBB</td>
  </tr>
  <tr>
    <td>CCC</td>
  </tr>
 </tbody>        :
<table>

   copyright(c) 2007 kuwata-lab.com all rights reserved.
Benchmark Environment


                                              1: <html>
‣ 400                                            .....                  : 53
 10,000                                      53: <table>
                                             54: <% for item in list %>
                                             55: <tr>
‣ 10                                         56: <td><%= item['symbol'] %></td>
                                             57: <td><%= item['name'] %></td>
‣ MacOS X 10.4 Tiger                             .....
                                             79: </tr>                  : 17
 (CoreDuo 1.83GHz)                                                      x20
                                             80: <% end %>
‣ Ruby 1.8.6, eruby 1.0.5                    81: </table>
                                                 .....                   :5
                                             85: </html>

                 copyright(c) 2007 kuwata-lab.com all rights reserved.
Benchmark Result



50.0


37.5


25.0


12.5


  0
       C     eruby                                         ERB

           copyright(c) 2007 kuwata-lab.com all rights reserved.
#1:
MyEruby#1: First Implementation




  copyright(c) 2007 kuwata-lab.com all rights reserved.
#1:
            #1: First Implementation


 ### Program
   input.each_line do |line|
      line.scan(/(.*?)(<%=?|%>)/) do
        case $2
        when '<%' ; ...              1
        when '<%=' ; ...
        when '%>' ; ...
        ...
      end
   end
   ...
http://www.kuwata-lab.com/presen/erubybench-1.1.zip
           copyright(c) 2007 kuwata-lab.com all rights reserved.
#1:                                                      (2)
           #1: First Implementation (2)


                                    Ruby
### Translated
_buf = ""; _buf << "<html>n";
_buf << "<body>n"                1
_buf << " <table>n"
 for item in list ; _buf << "n";
_buf << " <tr>n"
_buf << " <td>"; _buf << (item['name']).to_s;
_buf << "</td>n";
_buf << " </tr>n";
 end ; _buf << "n";
...
            copyright(c) 2007 kuwata-lab.com all rights reserved.
#1:
                    #1: Benchmark Result



100


 75


 50


 25


  0
      C     eruby                      ERB                          MyEruby1

                copyright(c) 2007 kuwata-lab.com all rights reserved.
#2:
       #2: Never Split Into Lines




      copyright(c) 2007 kuwata-lab.com all rights reserved.
#2:
           #2: Never Split into Lines


## Before
  input.each_line do |line|
    line.scan(/(.*?)(<%=?|%>)/).each do
      ...
    end
  end

## After
  input.scan(/(.*?)(<%=?|%>)/m).each do
    ...
  end

          copyright(c) 2007 kuwata-lab.com all rights reserved.
#2:                                                               (2)
         #2: Never Split into Lines (2)



                                                         Ruby
## Before
_buf << "<html>n"
_buf << " <body>n"
_buf << " <h1>title</h1>n"

## After
_buf << '<html>
 <body>
   <h1>title</h1>
';

          copyright(c) 2007 kuwata-lab.com all rights reserved.
#2:
                          #2: Benchmark Result




100


 75


 50


 25


  0
      C    eruby             ERB                  MyEruby1                 MyEruby2

                   copyright(c) 2007 kuwata-lab.com all rights reserved.
#2:
                  #2: Benchmark Result




20


15


10


 5


 0
       C      eruby                                    MyEruby2

           copyright(c) 2007 kuwata-lab.com all rights reserved.
#3:
  #3: Replace Parsing with Pattern Matching




         copyright(c) 2007 kuwata-lab.com all rights reserved.
#3:
       #3: Replace Parsing with Pattern Matching

## Before
input.scan(/(.*?)(<%=?|%>)/m) do
  case $2
  when '<%=' ; kind = :expr
  when '<%' ; kind = :stmt
  when '%>' ; kind = :text
  ...

## After
input.scan(/(.*?)<%(=?)(.*?)%>/m) do
  text, equal, code = $1, $2, $3
  s << _convert_str(text, :text)
  s << _convert_str(code, equal=='=' ? :expr : :stmt)
  ...
              copyright(c) 2007 kuwata-lab.com all rights reserved.
#3:
                   #3: Benchmark Result



20


15


10


 5


 0
      C    eruby                 MyEruby2                            MyEruby3

             copyright(c) 2007 kuwata-lab.com all rights reserved.
#4:
      #4: Tune Up Regular Expressions




        copyright(c) 2007 kuwata-lab.com all rights reserved.
#4:
         #4: Tune Up Regular Expressions

## Before
input.scan(/(.*?)<%(=)?(.*?)%>/m) do
  text, equal, code = $1, $2, $3
  ...

## After
pos = 0
input.scan(/<%(=)?(.*?)%>/m) do
  equal, code = $1, $2
  match = Regexp.last_match
  len = match.begin(0) - pos
  text = eruby_str[pos, len]
  pos = match.end(0)
  ...
            copyright(c) 2007 kuwata-lab.com all rights reserved.
#4:
                      #4: Benchmark Result




20


15


10


 5


 0
     C    eruby       MyEruby2                 MyEruby3                MyEruby4

               copyright(c) 2007 kuwata-lab.com all rights reserved.
#5:
  #5: Inline Expansion of Method Call




      copyright(c) 2007 kuwata-lab.com all rights reserved.
#5:
        #5: Inline Expansion of Method Call

### Before
    ...
    s << _convert_str(code, :expr)
    s << _convert_str(code, :stmt)
    s << _convert_str(text, :text)
    ...

### After
    ...
    s << "_buf << (#{code}).to_s; "
    s << "#{code}; "
    s << "_buf << '#{text.gsub(/[']/, '&')}'; "
    ...
             copyright(c) 2007 kuwata-lab.com all rights reserved.
#5:
                      #5: Benchmark Result




20


15


10


 5


 0
     C    eruby MyEruby2           MyEruby3            MyEruby4        MyEruby5

               copyright(c) 2007 kuwata-lab.com all rights reserved.
#6:
                 #6: Array Buffer




      copyright(c) 2007 kuwata-lab.com all rights reserved.
#6:
                       #6: Array Buffer


                                                                      Ruby
### Before
_buf = '';
_buf << '<td>'; _buf << (n).to_s; _buf << '</td>';
_buf

### After                                                         String#<<
_buf = [];                                        1            Array#push()
_buf.push('<td>', n, '</td>');
_buf.join



              copyright(c) 2007 kuwata-lab.com all rights reserved.
#6:
                      #6: Benchmark Result



20


15


10


 5


 0
           by



                       2



                                       3



                                                        4



                                                                        5



                                                                                   6
                    by



                                    by



                                                     by



                                                                     by



                                                                                by
            u
         er



                 ru



                                 ru



                                                  ru



                                                                  ru



                                                                             ru
                 yE



                              yE



                                              yE



                                                               yE



                                                                             yE
                M



                             M



                                             M



                                                              M



                 copyright(c) 2007 kuwata-lab.com all rights reserved.      M
     C
#7:
          #7: Interpolation




copyright(c) 2007 kuwata-lab.com all rights reserved.
#7:
                   #7: Interpolation


                                                                  Ruby
### Before
_buf << '<tr>
<td>'; _buf << (n).to_s; _buf << '</td>
</tr>';
                                                            String#<<
### After
_buf << %Q`<tr>
<td>#{n}</td>
                                             "...str..."
</tr>`
                                             %Q`...str...`



          copyright(c) 2007 kuwata-lab.com all rights reserved.
#7:
                        #7: Benchmark Result




20


15


10


 5


 0
             y


                    2


                                3


                                              4


                                                             5


                                                                            6


                                                                                      7
           ub


                 by


                             by


                                           by


                                                          by


                                                                         by


                                                                                   by
         er


                ru


                           ru


                                       ru


                                                      ru


                                                                    ru


                                                                                   ru
              yE


                         yE


                                     yE


                                                    yE


                                                                  yE


                                                                                 yE
             M


                        M


                                    M


                                                   M


                                                                 M


                 copyright(c) 2007 kuwata-lab.com all rights reserved.
                                                                                M
     C
#8:
                  #7: File Caching




      copyright(c) 2007 kuwata-lab.com all rights reserved.
#8:
                      #8: File Caching


## After
def convert_file(filename, cachename=nil)
 cachename ||= filename + '.cache'
 if                               or
    prog = convert(File.read(filename))
                                     (prog)
 else
    prog =
 end
 return prog                    Ruby
end

            copyright(c) 2007 kuwata-lab.com all rights reserved.
#8:
               #8: Benchmark Result



20


15


10


 5


 0
               y

               2


               3


               4


               5


               6


               7


               8
           ub

            by


            by


            by


            by


            by


            by


            by
         er

        ru


        ru


        ru


        ru


        ru


        ru


        ru
      yE


      yE


      yE


      yE


      yE


      yE


      yE
     M


     M


     M


     M


     M


     M


     M
           copyright(c) 2007 kuwata-lab.com all rights reserved.
 C
#9:
          #7: Make Methods




  copyright(c) 2007 kuwata-lab.com all rights reserved.
#9:
                      #9: Make Methods

### Before
 prog = myeruby.convert_file(filename)
 eval prog

### After                  Ruby
 def define_method(body, args=[])
  eval "def self.evaluate(#{args.join(',')}); #{body}; end"
 end
 prog = myeruby.convert_file(filename)
 args = ['list']
 myeruby.define_method(prog, args)
 myeruby.evaluate()
              copyright(c) 2007 kuwata-lab.com all rights reserved.
#9:
               #9: Benchmark Result



20


15


10


 5


 0
               y

               2

               3

               4

               5

               6

               7

               8

               9
           ub

            by

            by

            by

            by

            by

            by

            by

            by
         er

        ru

        ru

        ru

        ru

        ru

        ru

        ru

        ru
      yE

      yE

      yE

      yE

      yE

      yE

      yE

      yE
     M

     M

     M

     M

     M

     M

     M

     M
           copyright(c) 2007 kuwata-lab.com all rights reserved.
 C
Principles of Tuning
                                                                     :
#
#2                   1                                      69.17
#8                                                          2.44
#9                                                                  2.26
#2                                          1                       4.91
#5                                                          2.11
#6                                     Array#push()                 0.94
#7                                                                  0.94
#3                                                          4.20
#4                                                          2.12
    copyright(c) 2007 kuwata-lab.com all rights reserved.
Comparison with Competitors

 Lang                        Solution                              Time(sec)
Ruby      eruby                                                      15.32
          ERB                                                        42.67
          MyEruby7 (interporation)                                   10.42
          MyEruby8 (cached)                                          8.02
          MyEruby9 (method)                                          5.11
 Perl     Template-Toolkit                                           26.40

Python    Django                                                     50.55
          Kid (TurboGears)                                          344.16
 Java     Jakarta Velocity                                           13.24
           copyright(c) 2007 kuwata-lab.com all rights reserved.
Summary




copyright(c) 2007 kuwata-lab.com all rights reserved.
Result



‣C      1.5                    Ruby
    •                        2                                    3

    •

‣
    •    Java             Ruby


          copyright(c) 2007 kuwata-lab.com all rights reserved.
Conclusion



‣

    •

‣
    •


        copyright(c) 2007 kuwata-lab.com all rights reserved.
one more minute...



   copyright(c) 2007 kuwata-lab.com all rights reserved.
Erubis

             •    ERB             3          eruby              10%
             •
eRuby        •                                            <% %>
             •    <%= %>               HTML escape
             •    YAML
             •    Ruby
             •                               (C/Java/PHP/Perl/Scheme/JavaSript)

            • RoR                                       30%           (    )


        copyright(c) 2007 kuwata-lab.com all rights reserved.
thank you



copyright(c) 2007 kuwata-lab.com all rights reserved.

Weitere ähnliche Inhalte

Was ist angesagt?

Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in PerlLaurent Dami
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)ngotogenome
 
Advanced python
Advanced pythonAdvanced python
Advanced pythonEU Edge
 
Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)James Titcumb
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Pythonkwatch
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaPatrick Allaert
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objectsjulien pauli
 
閒聊Python應用在game server的開發
閒聊Python應用在game server的開發閒聊Python應用在game server的開發
閒聊Python應用在game server的開發Eric Chen
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Fwdays
 
NativeBoost
NativeBoostNativeBoost
NativeBoostESUG
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...James Titcumb
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalKent Ohashi
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Advanced Python, Part 2
Advanced Python, Part 2Advanced Python, Part 2
Advanced Python, Part 2Zaar Hai
 

Was ist angesagt? (20)

Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
 
Advanced python
Advanced pythonAdvanced python
Advanced python
 
Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)Diving into HHVM Extensions (php[tek] 2016)
Diving into HHVM Extensions (php[tek] 2016)
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
閒聊Python應用在game server的開發
閒聊Python應用在game server的開發閒聊Python應用在game server的開發
閒聊Python應用在game server的開發
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
 
NativeBoost
NativeBoostNativeBoost
NativeBoost
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Advanced Python, Part 2
Advanced Python, Part 2Advanced Python, Part 2
Advanced Python, Part 2
 

Ähnlich wie Cより速いRubyプログラム

The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for RubyHiroshi SHIBATA
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9tomaspavelka
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRubyFrederic Jean
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingBozhidar Batsov
 
MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介kwatch
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mrubyHiroshi SHIBATA
 
Whatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processWhatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processguest3379bd
 
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxRubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxDr Nic Williams
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Scott Keck-Warren
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHiroshi SHIBATA
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceJesse Vincent
 

Ähnlich wie Cより速いRubyプログラム (20)

The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Ruby 1.9
Ruby 1.9Ruby 1.9
Ruby 1.9
 
New features in Ruby 2.5
New features in Ruby 2.5New features in Ruby 2.5
New features in Ruby 2.5
 
MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介MySQLドライバの改良と軽量O/Rマッパーの紹介
MySQLドライバの改良と軽量O/Rマッパーの紹介
 
Sinatra
SinatraSinatra
Sinatra
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mruby
 
Whatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the processWhatever it takes - Fixing SQLIA and XSS in the process
Whatever it takes - Fixing SQLIA and XSS in the process
 
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxRubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
Debugging TV Frame 0x13
Debugging TV Frame 0x13Debugging TV Frame 0x13
Debugging TV Frame 0x13
 

Mehr von kwatch

How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Pythonkwatch
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアルkwatch
 
なんでもID
なんでもIDなんでもID
なんでもIDkwatch
 
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方kwatch
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方kwatch
 
O/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐO/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐkwatch
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?kwatch
 
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)kwatch
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!kwatch
 
PHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するPHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するkwatch
 
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?kwatch
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策kwatch
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門kwatch
 
Pretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/MercurialPretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/Mercurialkwatch
 
Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -kwatch
 
文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみたkwatch
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"kwatch
 
Javaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンJavaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンkwatch
 
Underlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R MapperUnderlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R Mapperkwatch
 
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -kwatch
 

Mehr von kwatch (20)

How to make the fastest Router in Python
How to make the fastest Router in PythonHow to make the fastest Router in Python
How to make the fastest Router in Python
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアル
 
なんでもID
なんでもIDなんでもID
なんでもID
 
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
Nippondanji氏に怒られても仕方ない、配列型とJSON型の使い方
 
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
【SQLインジェクション対策】徳丸先生に怒られない、動的SQLの安全な組み立て方
 
O/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐO/Rマッパーによるトラブルを未然に防ぐ
O/Rマッパーによるトラブルを未然に防ぐ
 
正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?正規表現リテラルは本当に必要なのか?
正規表現リテラルは本当に必要なのか?
 
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
【公開終了】Python4PHPer - PHPユーザのためのPython入門 (Python2.5)
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!
 
PHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較するPHPとJavaScriptにおけるオブジェクト指向を比較する
PHPとJavaScriptにおけるオブジェクト指向を比較する
 
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
SQL上級者こそ知って欲しい、なぜO/Rマッパーが重要か?
 
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
 
Pretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/MercurialPretty Good Branch Strategy for Git/Mercurial
Pretty Good Branch Strategy for Git/Mercurial
 
Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -Oktest - a new style testing library for Python -
Oktest - a new style testing library for Python -
 
文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた文字列結合のベンチマークをいろんな処理系でやってみた
文字列結合のベンチマークをいろんな処理系でやってみた
 
I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"I have something to say about the buzz word "From Java to Ruby"
I have something to say about the buzz word "From Java to Ruby"
 
Javaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジンJavaより速いLL用テンプレートエンジン
Javaより速いLL用テンプレートエンジン
 
Underlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R MapperUnderlaying Technology of Modern O/R Mapper
Underlaying Technology of Modern O/R Mapper
 
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
 

Kürzlich hochgeladen

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Kürzlich hochgeladen (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Cより速いRubyプログラム

  • 1. RubyKaigi 2007 Session C Ruby An Example of Ruby Program Faster Than C makoto kuwata http://www.kuwata-lab.com copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 3. 2007 Script Languages in 2007 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 4. PS3 Break Away from PS3 Syndrome ‣ PS3/PSP … • ‣ Wii/DS … • copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 5. Script Languages can't be Center Player ‣ Java • Java • ≠ ‣ • • copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 6. Problems and Truth about Script Languages ✓ ✓ ✓ copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 7. About This Presentation copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 8. Point ≠ Language Speed ≠ Application Speed copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 9. Overview ‣ : ‣ : C Ruby ‣ : eRuby ‣ : C ≦ Ruby ≪≪≪≪≪ C copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 10. Conclusion ‣ • ‣ • copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 11. eRuby Introduction to eRuby copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 12. eRuby What is eRuby? ‣ eRuby (Embedded Ruby) … Ruby ( ) ‣ eRuby … Ruby Ruby • eruby … C • ERB … pure Ruby Ruby1.8 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 13. Example <table> <tbody> <% for item in list %> <tr> <td><%= item %></td> </tr> <% end %> </tbody> <% ... ... %> <table> <%= ... ... %> copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 14. C eruby Ruby Script Translated by eruby print "<table>n" print " <tbody>n" for item in list ; print "n" print " <tr>n" print " <td>"; print(( item )); print "</td>n" print " </tr>n" end ; print "n" print " </tbody>n" print print "<table>n" 1 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 15. ERB Ruby Script Translated by ERB _erbout = ""; _erbout.concat "<table>n" _erbout.concat " <tbody>n" for item in list ; _erbout.concat "n" _erbout.concat " <tr>n" _erbout.concat " <td>"; _erbout.concat(( item ).to_s); _erbout.concat "</td>n" _erbout.concat " </tr>n" end ; _erbout.concat "n" _erbout.concat " </tbody>n" _erbout.concat "<table>n" _erbout 1 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 16. Output Example <table> <tbody> <tr> <td>AAA</td> </tr> <tr> <td>BBB</td> </tr> <tr> <td>CCC</td> </tr> </tbody> : <table> copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 17. Benchmark Environment 1: <html> ‣ 400 ..... : 53 10,000 53: <table> 54: <% for item in list %> 55: <tr> ‣ 10 56: <td><%= item['symbol'] %></td> 57: <td><%= item['name'] %></td> ‣ MacOS X 10.4 Tiger ..... 79: </tr> : 17 (CoreDuo 1.83GHz) x20 80: <% end %> ‣ Ruby 1.8.6, eruby 1.0.5 81: </table> ..... :5 85: </html> copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 18. Benchmark Result 50.0 37.5 25.0 12.5 0 C eruby ERB copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 19. #1: MyEruby#1: First Implementation copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 20. #1: #1: First Implementation ### Program input.each_line do |line| line.scan(/(.*?)(<%=?|%>)/) do case $2 when '<%' ; ... 1 when '<%=' ; ... when '%>' ; ... ... end end ... http://www.kuwata-lab.com/presen/erubybench-1.1.zip copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 21. #1: (2) #1: First Implementation (2) Ruby ### Translated _buf = ""; _buf << "<html>n"; _buf << "<body>n" 1 _buf << " <table>n" for item in list ; _buf << "n"; _buf << " <tr>n" _buf << " <td>"; _buf << (item['name']).to_s; _buf << "</td>n"; _buf << " </tr>n"; end ; _buf << "n"; ... copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 22. #1: #1: Benchmark Result 100 75 50 25 0 C eruby ERB MyEruby1 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 23. #2: #2: Never Split Into Lines copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 24. #2: #2: Never Split into Lines ## Before input.each_line do |line| line.scan(/(.*?)(<%=?|%>)/).each do ... end end ## After input.scan(/(.*?)(<%=?|%>)/m).each do ... end copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 25. #2: (2) #2: Never Split into Lines (2) Ruby ## Before _buf << "<html>n" _buf << " <body>n" _buf << " <h1>title</h1>n" ## After _buf << '<html> <body> <h1>title</h1> '; copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 26. #2: #2: Benchmark Result 100 75 50 25 0 C eruby ERB MyEruby1 MyEruby2 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 27. #2: #2: Benchmark Result 20 15 10 5 0 C eruby MyEruby2 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 28. #3: #3: Replace Parsing with Pattern Matching copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 29. #3: #3: Replace Parsing with Pattern Matching ## Before input.scan(/(.*?)(<%=?|%>)/m) do case $2 when '<%=' ; kind = :expr when '<%' ; kind = :stmt when '%>' ; kind = :text ... ## After input.scan(/(.*?)<%(=?)(.*?)%>/m) do text, equal, code = $1, $2, $3 s << _convert_str(text, :text) s << _convert_str(code, equal=='=' ? :expr : :stmt) ... copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 30. #3: #3: Benchmark Result 20 15 10 5 0 C eruby MyEruby2 MyEruby3 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 31. #4: #4: Tune Up Regular Expressions copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 32. #4: #4: Tune Up Regular Expressions ## Before input.scan(/(.*?)<%(=)?(.*?)%>/m) do text, equal, code = $1, $2, $3 ... ## After pos = 0 input.scan(/<%(=)?(.*?)%>/m) do equal, code = $1, $2 match = Regexp.last_match len = match.begin(0) - pos text = eruby_str[pos, len] pos = match.end(0) ... copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 33. #4: #4: Benchmark Result 20 15 10 5 0 C eruby MyEruby2 MyEruby3 MyEruby4 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 34. #5: #5: Inline Expansion of Method Call copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 35. #5: #5: Inline Expansion of Method Call ### Before ... s << _convert_str(code, :expr) s << _convert_str(code, :stmt) s << _convert_str(text, :text) ... ### After ... s << "_buf << (#{code}).to_s; " s << "#{code}; " s << "_buf << '#{text.gsub(/[']/, '&')}'; " ... copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 36. #5: #5: Benchmark Result 20 15 10 5 0 C eruby MyEruby2 MyEruby3 MyEruby4 MyEruby5 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 37. #6: #6: Array Buffer copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 38. #6: #6: Array Buffer Ruby ### Before _buf = ''; _buf << '<td>'; _buf << (n).to_s; _buf << '</td>'; _buf ### After String#<< _buf = []; 1 Array#push() _buf.push('<td>', n, '</td>'); _buf.join copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 39. #6: #6: Benchmark Result 20 15 10 5 0 by 2 3 4 5 6 by by by by by u er ru ru ru ru ru yE yE yE yE yE M M M M copyright(c) 2007 kuwata-lab.com all rights reserved. M C
  • 40. #7: #7: Interpolation copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 41. #7: #7: Interpolation Ruby ### Before _buf << '<tr> <td>'; _buf << (n).to_s; _buf << '</td> </tr>'; String#<< ### After _buf << %Q`<tr> <td>#{n}</td> "...str..." </tr>` %Q`...str...` copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 42. #7: #7: Benchmark Result 20 15 10 5 0 y 2 3 4 5 6 7 ub by by by by by by er ru ru ru ru ru ru yE yE yE yE yE yE M M M M M copyright(c) 2007 kuwata-lab.com all rights reserved. M C
  • 43. #8: #7: File Caching copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 44. #8: #8: File Caching ## After def convert_file(filename, cachename=nil) cachename ||= filename + '.cache' if or prog = convert(File.read(filename)) (prog) else prog = end return prog Ruby end copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 45. #8: #8: Benchmark Result 20 15 10 5 0 y 2 3 4 5 6 7 8 ub by by by by by by by er ru ru ru ru ru ru ru yE yE yE yE yE yE yE M M M M M M M copyright(c) 2007 kuwata-lab.com all rights reserved. C
  • 46. #9: #7: Make Methods copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 47. #9: #9: Make Methods ### Before prog = myeruby.convert_file(filename) eval prog ### After Ruby def define_method(body, args=[]) eval "def self.evaluate(#{args.join(',')}); #{body}; end" end prog = myeruby.convert_file(filename) args = ['list'] myeruby.define_method(prog, args) myeruby.evaluate() copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 48. #9: #9: Benchmark Result 20 15 10 5 0 y 2 3 4 5 6 7 8 9 ub by by by by by by by by er ru ru ru ru ru ru ru ru yE yE yE yE yE yE yE yE M M M M M M M M copyright(c) 2007 kuwata-lab.com all rights reserved. C
  • 49. Principles of Tuning : # #2 1 69.17 #8 2.44 #9 2.26 #2 1 4.91 #5 2.11 #6 Array#push() 0.94 #7 0.94 #3 4.20 #4 2.12 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 50. Comparison with Competitors Lang Solution Time(sec) Ruby eruby 15.32 ERB 42.67 MyEruby7 (interporation) 10.42 MyEruby8 (cached) 8.02 MyEruby9 (method) 5.11 Perl Template-Toolkit 26.40 Python Django 50.55 Kid (TurboGears) 344.16 Java Jakarta Velocity 13.24 copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 52. Result ‣C 1.5 Ruby • 2 3 • ‣ • Java Ruby copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 53. Conclusion ‣ • ‣ • copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 54. one more minute... copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 55. Erubis • ERB 3 eruby 10% • eRuby • <% %> • <%= %> HTML escape • YAML • Ruby • (C/Java/PHP/Perl/Scheme/JavaSript) • RoR 30% ( ) copyright(c) 2007 kuwata-lab.com all rights reserved.
  • 56. thank you copyright(c) 2007 kuwata-lab.com all rights reserved.