This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Benchmark.bm do |x| | |
| types = { | |
| banana: 0.2, | |
| lemon: 0.4, | |
| orange: 0.4 | |
| } | |
| x.report("select") do | |
| 1.upto(10000) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # :"test" is faster than "test".intern ... | |
| Benchmark.bm do |x| | |
| test = 'test' | |
| x.report { 1000000.times { "test".intern } } | |
| x.report { 1000000.times { :"test" } } | |
| end | |
| # user system total real | |
| # 0.430000 0.000000 0.430000 ( 0.429735) | |
| # 0.080000 0.000000 0.080000 ( 0.082169) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| Benchmark.bm do |x| | |
| empty = [] | |
| not_empty = [:foo, :bar, :baz] | |
| # (size == 0) is faster than empty? for both empty | |
| # and non-empty arrays. | |
| x.report { 1000000.times { empty.size == 0 } } | |
| x.report { 1000000.times { not_empty.size == 0 } } | |
| # user system total real | |
| # 0.100000 0.000000 0.100000 ( 0.098931) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| array = (1..1_000_000).to_a | |
| hash = Hash[array.map {|x| [x, nil]}] | |
| Benchmark.bm(15) do |x| | |
| x.report("Array.include?") { 1000.times { array.include?(500_000) } } | |
| x.report("Hash.include?") { 1000.times { hash.include?(500_000) } } | |
| end | |
| # user system total real |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ClawsC5 = 0 | |
| # Brown = 1 | |
| # Penn = 2 | |
| # Negra = 3 | |
| # Penn Chinese = 4 | |
| # "Simplified" Stanford French Tags = 5 | |
| [ | |
| 'Adjective', ['AJ0', 'JJ', 'JJ', '', 'JJ', 'A'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="us-ascii" standalone="no" ?> | |
| <treat> | |
| <sentence id='70222715664980' language='eng' tag_set='penn' dependencies=''> <word id='70222715690540' stem='Happi' tag='NN' tag_opt='' tag_set='penn' category='noun' dependencies=''>Happiness</word> | |
| <word id='70222715689240' stem='is' tag='VBZ' tag_opt='' tag_set='penn' category='verb' dependencies=''>is</word> | |
| <word id='70222715688060' stem='not' tag='RB' tag_opt='' tag_set='penn' category='adverb' dependencies=''>not</word> | |
| <word id='70222715686880' stem='an' tag='DT' tag_opt='' tag_set='penn' category='determiner' dependencies=''>an</word> | |
| <word id='70222715685640' stem='ideal' tag='NN' tag_opt='' tag_set='penn' category='noun' dependencies=''>ideal</word> | |
| <word id='70222715684460' stem='of' tag='IN' tag_opt='' tag_set='penn' category='preposition' dependencies=''>of</word> | |
| <word id='70222715683260' stem='reason' tag='NN' tag_opt='' tag_set='penn' category='noun' dependencies=''>reason</word> | |
| <punctuation id='70222715698440' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'date' | |
| Treat.sweeten! | |
| s = Section "2011/12/23 \n - Obama and Sarkozy met on January 1st to investigate the possibility of a new rescue plan. President Sarkozy is to meet Merkel next Tuesday in Berlin." | |
| s.do( | |
| :chunk, :segment, :parse, :time, :date, | |
| :visualize => [ | |
| :dot, { | |
| :file => 'test-date-time-extraction.dot', | |
| :colors => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'treat' | |
| Treat.sweeten! | |
| p = Paragraph "Obama and Sarkozy met on January 1st to investigate the possibility of a new rescue plan." + | |
| "President Sarkozy is to meet Merkel next Tuesday in Berlin." | |
| p.do( | |
| :coreferences, | |
| :visualize => [ | |
| :dot, { | |
| :file => 'ner-coref-extraction.dot', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function send($host, $method, $path, $data, $useragent = null) | |
| { | |
| $str_data = ''; | |
| foreach ($data as $key => $value) | |
| { | |
| if ($str_data != '') $str_data .= '&'; | |
| $str_data .= rawurlencode($key) . '=' . rawurlencode($value); | |
| } | |
| // Supply a default method of GET if the one passed was empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| require 'set' | |
| a = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] | |
| h = {'a' => 1, 'b' => 1, 'c' => 1, 'd' => 1, | |
| 'e' => 1, 'f' => 1, 'g' => 1} | |
| s = Set.new(a) | |
| Benchmark.bm do |x| |
OlderNewer