ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby
@ 2020-08-20 14:03 gamelinks007
  2020-08-21 18:37 ` [ruby-dev:50949] [Ruby master Feature#17127] Some TrueClass methods are " takashikkbn
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gamelinks007 @ 2020-08-20 14:03 UTC (permalink / raw)
  To: ruby-dev

Issue #17127 has been reported by S_H_ (Shun Hiraoka).

----------------------------------------
Feature #17127: Some TrueClass methods is faster if implemented in Ruby
https://bugs.ruby-lang.org/issues/17127

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------
Some TrueClass methods is faster if implemented in Ruby code.

like this.


```ruby
class TrueClass
  def to_s
    "true".freeze
  end
  alias_method :inspect, :to_s

  def |(bool)
    true
  end
end

```

benchmark file:
```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
loop_count: 1000000
```


benchmark result:

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     66.001M|   91.927M|
|         |           -|     1.39x|
|inspect  |     70.464M|   97.220M|
|         |           -|     1.38x|
|or       |     61.434M|   86.484M|
|         |           -|     1.41x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`.

Probably,  inline method cache was able to speed up theese methods.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50949] [Ruby master Feature#17127] Some TrueClass methods are faster if implemented in Ruby
  2020-08-20 14:03 [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby gamelinks007
@ 2020-08-21 18:37 ` takashikkbn
  2020-08-24 14:34 ` [ruby-dev:50950] " gamelinks007
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: takashikkbn @ 2020-08-21 18:37 UTC (permalink / raw)
  To: ruby-dev

Issue #17127 has been updated by k0kubun (Takashi Kokubun).


off topic: If you write an entire ticket in English, I think you should post your ticket to ruby-core to attract more audiences instead of ruby-dev, which has been for tickets written in Japanese.

----------------------------------------
Feature #17127: Some TrueClass methods are faster if implemented in Ruby
https://bugs.ruby-lang.org/issues/17127#change-87153

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------
Some TrueClass methods are faster if implemented in Ruby code.

like this.


```ruby
class TrueClass
  def to_s
    "true".freeze
  end
  alias_method :inspect, :to_s

  def |(bool)
    true
  end
end

```

benchmark file:
```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
loop_count: 1000000
```


benchmark result:

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     66.001M|   91.927M|
|         |           -|     1.39x|
|inspect  |     70.464M|   97.220M|
|         |           -|     1.38x|
|or       |     61.434M|   86.484M|
|         |           -|     1.41x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`.

Probably,  inline method cache was able to speed up these methods.

pull request:
https://github.com/ruby/ruby/pull/3435



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50950] [Ruby master Feature#17127] Some TrueClass methods are faster if implemented in Ruby
  2020-08-20 14:03 [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby gamelinks007
  2020-08-21 18:37 ` [ruby-dev:50949] [Ruby master Feature#17127] Some TrueClass methods are " takashikkbn
@ 2020-08-24 14:34 ` gamelinks007
  2020-08-26  9:05 ` [ruby-dev:50951] " gamelinks007
  2020-11-05  7:11 ` [ruby-dev:50969] " gamelinks007
  3 siblings, 0 replies; 5+ messages in thread
From: gamelinks007 @ 2020-08-24 14:34 UTC (permalink / raw)
  To: ruby-dev

Issue #17127 has been updated by S_H_ (Shun Hiraoka).


k0kubun (Takashi Kokubun) wrote in #note-3:
> off topic: If you write an entire ticket in English, I think you should post your ticket to ruby-core to attract more audiences instead of ruby-dev, which has been for tickets written in Japanese.

Thanks!

----------------------------------------
Feature #17127: Some TrueClass methods are faster if implemented in Ruby
https://bugs.ruby-lang.org/issues/17127#change-87170

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------
Some TrueClass methods are faster if implemented in Ruby code.

like this.


```ruby
class TrueClass
  def to_s
    "true".freeze
  end
  alias_method :inspect, :to_s

  def |(bool)
    true
  end
end

```

benchmark file:
```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
loop_count: 1000000
```


benchmark result:

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     66.001M|   91.927M|
|         |           -|     1.39x|
|inspect  |     70.464M|   97.220M|
|         |           -|     1.38x|
|or       |     61.434M|   86.484M|
|         |           -|     1.41x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`.

Probably,  inline method cache was able to speed up these methods.

pull request:
https://github.com/ruby/ruby/pull/3435



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50951] [Ruby master Feature#17127] Some TrueClass methods are faster if implemented in Ruby
  2020-08-20 14:03 [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby gamelinks007
  2020-08-21 18:37 ` [ruby-dev:50949] [Ruby master Feature#17127] Some TrueClass methods are " takashikkbn
  2020-08-24 14:34 ` [ruby-dev:50950] " gamelinks007
@ 2020-08-26  9:05 ` gamelinks007
  2020-11-05  7:11 ` [ruby-dev:50969] " gamelinks007
  3 siblings, 0 replies; 5+ messages in thread
From: gamelinks007 @ 2020-08-26  9:05 UTC (permalink / raw)
  To: ruby-dev

Issue #17127 has been updated by S_H_ (Shun Hiraoka).


these method able to speeding up implemented by Ruby code.

- `TrueClass#^`
- `TrueClass#&`

benchmark:

```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
  xor: |
    true ^ false
  and: |
    true & false
loop_count: 1000000

```

result: 

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     70.669M|   93.297M|
|         |           -|     1.32x|
|inspect  |     68.119M|   95.079M|
|         |           -|     1.40x|
|or       |     56.598M|   62.115M|
|         |           -|     1.10x|
|xor      |     59.137M|   70.666M|
|         |           -|     1.19x|
|and      |     41.956M|   46.382M|
|         |           -|     1.11x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is patched ruby.


----------------------------------------
Feature #17127: Some TrueClass methods are faster if implemented in Ruby
https://bugs.ruby-lang.org/issues/17127#change-87195

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------
Some TrueClass methods are faster if implemented in Ruby code.

like this.


```ruby
class TrueClass
  def to_s
    "true".freeze
  end
  alias_method :inspect, :to_s

  def |(bool)
    true
  end
end

```

benchmark file:
```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
loop_count: 1000000
```


benchmark result:

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     66.001M|   91.927M|
|         |           -|     1.39x|
|inspect  |     70.464M|   97.220M|
|         |           -|     1.38x|
|or       |     61.434M|   86.484M|
|         |           -|     1.41x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`.

Probably,  inline method cache was able to speed up these methods.

pull request:
https://github.com/ruby/ruby/pull/3435



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:50969] [Ruby master Feature#17127] Some TrueClass methods are faster if implemented in Ruby
  2020-08-20 14:03 [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby gamelinks007
                   ` (2 preceding siblings ...)
  2020-08-26  9:05 ` [ruby-dev:50951] " gamelinks007
@ 2020-11-05  7:11 ` gamelinks007
  3 siblings, 0 replies; 5+ messages in thread
From: gamelinks007 @ 2020-11-05  7:11 UTC (permalink / raw)
  To: ruby-dev

Issue #17127 has been updated by S_H_ (Shun Hiraoka).


recreate PR for marge `.rb` files

https://github.com/ruby/ruby/pull/3737

----------------------------------------
Feature #17127: Some TrueClass methods are faster if implemented in Ruby
https://bugs.ruby-lang.org/issues/17127#change-88358

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------
Some TrueClass methods are faster if implemented in Ruby code.

like this.


```ruby
class TrueClass
  def to_s
    "true".freeze
  end
  alias_method :inspect, :to_s

  def |(bool)
    true
  end
end

```

benchmark file:
```yaml
benchmark:
  to_s: |
    true.to_s
  inspect: |
    true.inspect
  or: |
    true | false
loop_count: 1000000
```


benchmark result:

```bash
sh@MyComputer:~/rubydev/build$ make benchmark/trueclass.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
# Iteration per second (i/s)

|         |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s     |     66.001M|   91.927M|
|         |           -|     1.39x|
|inspect  |     70.464M|   97.220M|
|         |           -|     1.38x|
|or       |     61.434M|   86.484M|
|         |           -|     1.41x|
```

`COMPARE_RUBY` is `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 2.8.0dev (2020-08-20T04:24:55Z master 6509652c13) [x86_64-linux]`.

Probably,  inline method cache was able to speed up these methods.

pull request:
https://github.com/ruby/ruby/pull/3435



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-05  7:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 14:03 [ruby-dev:50948] [Ruby master Feature#17127] Some TrueClass methods is faster if implemented in Ruby gamelinks007
2020-08-21 18:37 ` [ruby-dev:50949] [Ruby master Feature#17127] Some TrueClass methods are " takashikkbn
2020-08-24 14:34 ` [ruby-dev:50950] " gamelinks007
2020-08-26  9:05 ` [ruby-dev:50951] " gamelinks007
2020-11-05  7:11 ` [ruby-dev:50969] " gamelinks007

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).