require 'benchmark'
Benchmark.bmbm do |x|
  x.report("Array.push") do
    arrays = []
    1000.times do |i|
      arrays[i] = []
      (0...500000).each do |j|
        arrays[i] = j
      end
  
    
      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
    
  
  
    
  | -- ref: https://www.clear-code.com/blog/2020/12/22.html | |
| create type fts_bigram_token as (token text, position bigint); | |
| create or replace function fts_bigram_tokenize(value text) | |
| returns setof fts_bigram_token as $$ | |
| select trim(coalesce(lag(c) over (), '') || c), row_number() over () | |
| from ( | |
| select unnest( | |
| regexp_matches(regexp_replace(value, '[[:punct:]]', ' ', 'g') || ' ', '(?!\s\s).', 'g') | 
  
    
      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
    
  
  
    
  | import java.io.File; | |
| import java.io.IOException; | |
| import org.graalvm.polyglot.Context; | |
| import org.graalvm.polyglot.Source; | |
| import org.graalvm.polyglot.Value; | |
| public class GraalPolyglot { | |
| public static void main(String[] args) throws IOException { | |
| Source source = Source.newBuilder("ruby", new File(args[0])).build(); | 
  
    
      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
    
  
  
    
  | import java.io.File; | |
| import java.io.IOException; | |
| import org.graalvm.polyglot.Context; | |
| import org.graalvm.polyglot.Source; | |
| import org.graalvm.polyglot.Value; | |
| public class GraalPolyglot { | |
| public static void main(String[] args) throws IOException { | |
| Source source = Source.newBuilder("ruby", new File(args[0])).build(); | 
  
    
      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
    
  
  
    
  | import org.graalvm.polyglot.Context; | |
| import org.graalvm.polyglot.Value; | |
| public class GraalPolyglot { | |
| public static void main(String[] args) { | |
| try (Context context = Context.newBuilder().allowAllAccess(true).build()) { | |
| Value v = context.eval("ruby", "'Ruby String'"); | |
| context.getBindings("js").putMember("v", v); | |
| context.eval("js", "print('v=' + v)"); //=> v=Ruby String | |
| } | 
  
    
      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
    
  
  
    
  | ./configure \ | |
| $(ruby -e "puts RbConfig::CONFIG['configure_args']") \ | |
| CFLAGS=$(ruby -e "puts RbConfig::CONFIG['CFLAGS'] + ' -flto'") \ | |
| LDFLAGS=$(ruby -e "puts RbConfig::CONFIG['LDFLAGS'] + ' -flto'") \ | |
| --enable-shared \ | |
| --prefix=$(pwd)/install | 
No optimization:
        user     system      total        real
0.1kb   1.204809   0.005060   1.209869 (  1.210884)
1kb     1.309668   0.004896   1.314564 (  1.315971)
10kb    2.674302   0.077470   2.751772 (  2.755213)
100kb  29.982771  22.375113  52.357884 ( 52.386822)
500kb 122.625423  82.284026 204.909449 (205.018250)
600kb 1.006700 0.003676 1.010376 ( 1.010782)
  
    
      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 'json' | |
| require 'yajl' | |
| require 'msgpack' | |
| here = File.dirname(File.expand_path(__FILE__)) | |
| # https://catalog.data.gov/dataset/consumer-complaint-database | |
| VIEWS_OBJ = JSON.load(File.read("#{here}/views.json")) | |
| VIEWS_MSGPACK = MessagePack.pack(VIEWS_OBJ) | 
  
    
      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
    
  
  
    
  | public class Multistage<P> | |
| { | |
| public static class State<T> | |
| { | |
| private Object nextLambdaArgument; | |
| private boolean isNext; | |
| private State(Object nextLambdaArgument, boolean isNext) | |
| { | 
  
    
      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
    
  
  
    
  | source 'https://rubygems.org/' | |
| gemspec | |
NewerOlder