regex - performance

Another thing:

long_string.gsub(/abc.*?\n/, 'X') takes Million times longer than
long_string.gsub(/abc.*?$/, 'X' ) !

I also want to remove these \n ! - How can I do it otherwise?

Is it a bug? :wink: -- searching for "\n" should NOT take much longer than
for $ or any other char!

/abc[^\n]*?\n/ is not faster !

Opti

I believe that regexp engines are way to complex to find a bug with a
single pattern. Esp. When judging by runtime only, and esp. When u dont
communicate the test string.

No offence, but his looks more like a brain dump to me. IMO u need to be
more precise to get a valuable comment.

···

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, 12:05:

Another thing:

long_string.gsub(/abc.*?\n/, 'X') takes Million times longer than
long_string.gsub(/abc.*?$/, 'X' ) !

I also want to remove these \n ! - How can I do it otherwise?

Is it a bug? :wink: -- searching for "\n" should NOT take much longer than
for $ or any other char!

/abc[^\n]*?\n/ is not faster !

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

I watched it; it seems to depend on the contents of the string. In some
cases the difference in time is enormous.

···

Am 12.08.22 um 14:33 schrieb Der Zernichter:

I believe that regexp engines are way to complex to find a bug with a
single pattern. Esp. When judging by runtime only, and esp. When u
dont communicate the test string.

No offence, but his looks more like a brain dump to me. IMO u need to
be more precise to get a valuable comment.

Die Optimisten <inform@die-optimisten.net
<mailto:inform@die-optimisten.net>> schrieb am Fr., 12. Aug. 2022, 12:05: > > Another thing:

    long_string.gsub(/abc.*?\n/, 'X') takes Million times longer than
    long_string.gsub(/abc.*?$/, 'X' ) !

    I also want to remove these \n ! - How can I do it otherwise?

    Is it a bug? :wink: -- searching for "\n" should NOT take much
    longer than
    for $ or any other char!

    /abc[^\n]*?\n/ is not faster !

    Opti

Are u serious??

Ok, i wont further comment on your brain dump repeating what i just said
before on that topic.

This is not what ruby-talk is meant for IMO

···

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, 16:34:

I watched it; it seems to depend on the contents of the string. In some
cases the difference in time is enormous.

Am 12.08.22 um 14:33 schrieb Der Zernichter:

I believe that regexp engines are way to complex to find a bug with a
single pattern. Esp. When judging by runtime only, and esp. When u dont
communicate the test string.

No offence, but his looks more like a brain dump to me. IMO u need to be
more precise to get a valuable comment.

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, > 12:05:

Another thing:

long_string.gsub(/abc.*?\n/, 'X') takes Million times longer than
long_string.gsub(/abc.*?$/, 'X' ) !

I also want to remove these \n ! - How can I do it otherwise?

Is it a bug? :wink: -- searching for "\n" should NOT take much longer than
for $ or any other char!

/abc[^\n]*?\n/ is not faster !

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

You may find this insightful and a good starting point for how regexps can
go wrong:

That article links to this more in depth discussion:

As convenient as they are, regexps aren't a perfect solution. If the
performance of your regexp is bad, you may have to work at crafting a more
complicated one that avoids the issues, or you may even need to incorporate
other methods in addition to or instead of a single regexp.

-Jeremy

···

On Fri, Aug 12, 2022 at 9:34 AM Die Optimisten <inform@die-optimisten.net> wrote:

I watched it; it seems to depend on the contents of the string. In some
cases the difference in time is enormous.

Hi,
why these ugly words?
WHAT do you mean by 'brain dump' ?
It would be difficult to get this data again, but if you want to tyy it,
I could send you the data.
takes <0.5sec with /...$/, but >60secs with /...\n/ instead.
What's your problem?
Looks like the beginning reason is you were not willing (able?) to
understand why it makes sense to always return an array when executing
array[...]. - There are different views. Why don't you respect mine?
(And I'm not the only one...) - We should discuss the pros+cons and
maybe and try to convince others of the own sight.
Sad that's not possible to get a normal (technical) discussion here.

Maybe it would be nicer to not offend me. You could have used other words.
- You are not welcome to this list, if you're not able to be kind & stay
friendly.
I read the help for ruby2.3 - this version didn't have it! (Are you
reading it all again, when updating to a new version???)
- I also thought more of a gem or (core) function. - Who is thinking of
ruby-options?
- Are there methods, too (I don't want to see all, but only the
callstack of one specific method, as mentioned before)
Opti
PS: Another question: did you choose your name similar to 'Vernichter'?
- Then we have to be very careful interacting with you.
If you chose your name with the intention of 'Vernichter' then we should
ban you due to this fact already.

···

Am 12.08.22 um 16:46 schrieb Der Zernichter:

Are u serious??

Ok, i wont further comment on your brain dump repeating what i just
said before on that topic.

This is not what ruby-talk is meant for IMO

Die Optimisten <inform@die-optimisten.net
<mailto:inform@die-optimisten.net>> schrieb am Fr., 12. Aug. 2022, 16:34:

    I watched it; it seems to depend on the contents of the string. In
    some cases the difference in time is enormous.

    Am 12.08.22 um 14:33 schrieb Der Zernichter:

    I believe that regexp engines are way to complex to find a bug
    with a single pattern. Esp. When judging by runtime only, and
    esp. When u dont communicate the test string.

    No offence, but his looks more like a brain dump to me. IMO u
    need to be more precise to get a valuable comment.

    Die Optimisten <inform@die-optimisten.net
    <mailto:inform@die-optimisten.net>> schrieb am Fr., 12. Aug. >> 2022, 12:05:

        Another thing:

        long_string.gsub(/abc.*?\n/, 'X') takes Million times longer
        than
        long_string.gsub(/abc.*?$/, 'X' ) !

        I also want to remove these \n ! - How can I do it otherwise?

        Is it a bug? :wink: -- searching for "\n" should NOT take much
        longer than
        for $ or any other char!

        /abc[^\n]*?\n/ is not faster !

        Opti

    Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
    <mailto:ruby-talk-request@ruby-lang.org>?subject=unsubscribe>
    <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Thank you!
Is there a Queue(Array) of fixed length (adding automatically removes at
the other side)?

···

Am 12.08.22 um 17:00 schrieb Jeremy Bopp:

On Fri, Aug 12, 2022 at 9:34 AM Die Optimisten > <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:

    I watched it; it seems to depend on the contents of the string. In
    some cases the difference in time is enormous.

You may find this insightful and a good starting point for how regexps
can go wrong:

Regex Performance

That article links to this more in depth discussion:

Runaway Regular Expressions: Catastrophic Backtracking

As convenient as they are, regexps aren't a perfect solution. If the
performance of your regexp is bad, you may have to work at crafting a
more complicated one that avoids the issues, or you may even need to
incorporate other methods in addition to or instead of a single regexp.

-Jeremy

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Hi,
why these ugly words?
WHAT do you mean by 'brain dump' ?

I meant what i wrote before: i wrote performance analysis depends on the
input, which you did not include in you claim of a possible bug. And as an
answer u wrote: performance depends on the content of the string. So u did
just repeat what i wrote without any further information. My shortcut for
this was 'brain dump', yes. Because dump happens non-intentionally, i took
that wording to point out that your answer did not seem to intend to
provide any real answer to my request for more information.

It would be difficult to get this data again, but if you want to tyy it, I

could send you the data.

What is so difficult about a single string?

takes <0.5sec with /...$/, but >60secs with /...\n/ instead.

At least some more detail ...

What's your problem?

Looks like the beginning reason is you were not willing (able?) to
understand why it makes sense to always return an array when executing
array[...]. - There are different views.

This is not the thread isnt it?

Why don't you respect mine? (And I'm not the only one...) - We should

discuss the pros+cons and maybe and try to convince others of the own sight.
Sad that's not possible to get a normal (technical) discussion here.

I have no problem with your view - i never criticised it. I have my own and
state it like that.

My criticism if any is about how you communicate.

Maybe it would be nicer to not offend me. You could have used other words.

This is text chat. I am not responsible for how you feel about my exact
wording.

In most words there are chances to offend ppl, because the senders context
is always different from the recievers context.

- You are not welcome to this list, if you're not able to be kind & stay

friendly.
I read the help for ruby2.3 - this version didn't have it! (Are you
reading it all again, when updating to a new version???)

2.3? Seriously? Then why didnt u share this piece of information before?
Refering to an out-dated version of ruby is important for understanding the
test and its relevance. Claiming a bug in ruby 2.3 is different from a bug
in the latest release...

- I also thought more of a gem or (core) function. - Who is thinking of

ruby-options?

This is the default interaction with the ruby interpreter. Thats why it
came to my mind. --help is in many cases a good start for documentation IMO

- Are there methods, too (I don't want to see all, but only the callstack

of one specific method, as mentioned before)

I guess checking the source code for the relevant options might be useful

Opti

PS: Another question: did you choose your name similar to 'Vernichter'? -
Then we have to be very careful interacting with you.
If you chose your name with the intention of 'Vernichter' then we should
ban you due to this fact already.

I dont judge ppl by their names,but of course everybody is free to do
otherwise

···

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, 17:16:

Am 12.08.22 um 16:46 schrieb Der Zernichter:

Are u serious??

Ok, i wont further comment on your brain dump repeating what i just said
before on that topic.

This is not what ruby-talk is meant for IMO

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, > 16:34:

I watched it; it seems to depend on the contents of the string. In some
cases the difference in time is enormous.

Am 12.08.22 um 14:33 schrieb Der Zernichter:

I believe that regexp engines are way to complex to find a bug with a
single pattern. Esp. When judging by runtime only, and esp. When u dont
communicate the test string.

No offence, but his looks more like a brain dump to me. IMO u need to be
more precise to get a valuable comment.

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. >> 2022, 12:05:

Another thing:

long_string.gsub(/abc.*?\n/, 'X') takes Million times longer than
long_string.gsub(/abc.*?$/, 'X' ) !

I also want to remove these \n ! - How can I do it otherwise?

Is it a bug? :wink: -- searching for "\n" should NOT take much longer than
for $ or any other char!

/abc[^\n]*?\n/ is not faster !

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe> <ruby-talk-request@ruby-lang.org?subject=unsubscribe><http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt; <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

I am not aware of such a thing, but you could wrap or extend the standard
Array or Queue classes to implement something like that. Just override the
writer methods such as #push or #unshift to drop the element from the
appropriate end of the structure when the maximum capacity is reached.

-Jeremy

···

On Fri, Aug 12, 2022 at 10:20 AM Die Optimisten <inform@die-optimisten.net> wrote:

Thank you!
Is there a Queue(Array) of fixed length (adding automatically removes at
the other side)?

[1] https://github.com/celluloid/celluloid/blob/v0.18.0/lib/celluloid/logging/ring_buffer.rb

  require 'celluloid/logging/ring_buffer'

  q = Celluloid::RingBuffer.new(5)
  p q.instance_variable_get(:@buffer)
  #=> [nil, nil, nil, nil, nil]

  9.times do |i|
    q << i
    p q.instance_variable_get(:@buffer)
  end
  #=> [0, nil, nil, nil, nil]
  #=> [0, 1, nil, nil, nil]
  #=> [0, 1, 2, nil, nil]
  #=> [0, 1, 2, 3, nil]
  #=> [0, 1, 2, 3, 4]
  #=> [5, 1, 2, 3, 4]
  #=> [5, 6, 2, 3, 4]
  #=> [5, 6, 7, 3, 4]
  #=> [5, 6, 7, 8, 4]

  6.times do
    p q.shift
  end
  #=> 4
  #=> 5
  #=> 6
  #=> 7
  #=> 8
  #=> nil

[2] A simple ring buffer for Ruby. · GitHub

  require_relative './ringbuffer'

  q = RingBuffer.new(5)
  p q
  #=>

  9.times do |i|
    q << i
    p q
  end
  #=> [0]
  #=> [0, 1]
  #=> [0, 1, 2]
  #=> [0, 1, 2, 3]
  #=> [0, 1, 2, 3, 4]
  #=> [1, 2, 3, 4, 5]
  #=> [2, 3, 4, 5, 6]
  #=> [3, 4, 5, 6, 7]
  #=> [4, 5, 6, 7, 8]

  6.times do
    p q.shift
  end
  #=> 4
  #=> 5
  #=> 6
  #=> 7
  #=> 8
  #=> nil

···

On 8/12/22, Die Optimisten <inform@die-optimisten.net> wrote:

Is there a Queue(Array) of fixed length (adding automatically removes at
the other side)?

Hello
Sorry - I have to anwer this:

[...]My shortcut for this was 'brain dump', yes. Because dump happens
non-intentionally, i took that wording to point out that your answer
did not seem to intend to provide any real answer to my request for
more information.

    It would be difficult to get this data again, but if you want to
    tyy it, I could send you the data.

What is so difficult about a single string?

You could imagine that size of a string could be in some cases more
important than the number of strings: its one string, but in this case
it's MBs in size. So I will NOT send it to this mailing-list (others
will thank for that).

What's your problem?

    Looks like the beginning reason is you were not willing (able?) to
    understand why it makes sense to always return an array when
    executing array[...]. - There are different views.

This is not the thread isnt it?

No, it's a 'Zernichter - thread'. (More about 'you', than programming)

    Why don't you respect mine? (And I'm not the only one...) - We
    should discuss the pros+cons and maybe and try to convince others
    of the own sight.
    Sad that's not possible to get a normal (technical) discussion here.

I have no problem with your view - i never criticised it. I have my
own and state it like that.

My criticism if any is about how you communicate.

    Maybe it would be nicer to not offend me. You could have used
    other words.

This is text chat. I am not responsible for how you feel about my
exact wording.

Is that your real anser? - Everyone is responsible for what he/she is
doing...

Ruby claim: be kind to other people! - Sure, there a other lists using
different standards.

In most words there are chances to offend ppl, because the senders
context is always different from the recievers context.

I don't think so. If you're describing (technical) things and use nice
words, that can't be offending.
- You know which of your words I'm referring.

    - You are not welcome to this list, if you're not able to be kind
    & stay friendly.
    I read the help for ruby2.3 - this version didn't have it! (Are
    you reading it all again, when updating to a new version???)

2.3? Seriously? Then why didnt u share this piece of information
before? Refering to an out-dated version of ruby is important for
understanding the test and its relevance. Claiming a bug in ruby 2.3
is different from a bug in the latest release...

NOW I'm using a newer version, but didn't read the help again. (as
mentioned before)
- I don't think that all these details are of interesting in this list,

    - Are there methods, too (I don't want to see all, but only the
    callstack of one specific method, as mentioned before)

I guess checking the source code for the relevant options might be useful

Yes, that's always true, but perhaps there're easier ways available...
Therefore my question.

(Yes, you can always read the sourcecodes - then maybe we would not have
ANY need for this list...)

    Opti
    PS: Another question: did you choose your name similar to
    'Vernichter'? - Then we have to be very careful interacting with you.
    If you chose your name with the intention of 'Vernichter' then we
    should ban you due to this fact already.

I dont judge ppl by their names,but of course everybody is free to do
otherwise.

Because it's stated 'Der Zernichter' it looks like to be not your
real-name, but an artificial name you chose. - How did you came to that,
what's the aim to use such name? (including 'Der', = 'The
Innihilator/Wrecker')!

Opti

Sorry, list - this is my last post to this thread, I promise

Hello
Sorry - I have to anwer this:

No, u dont have to, but hey ....

[...]My shortcut for this was 'brain dump', yes. Because dump happens
non-intentionally, i took that wording to point out that your answer did
not seem to intend to provide any real answer to my request for more
information.

It would be difficult to get this data again, but if you want to tyy it, I

could send you the data.

What is so difficult about a single string?

You could imagine that size of a string could be in some cases more
important than the number of strings: its one string, but in this case it's
MBs in size. So I will NOT send it to this mailing-list (others will thank
for that).

Then upload it somewhere and post a link. Regexp discussion about
performance without the input string is simply useless IMO

What's your problem?

Looks like the beginning reason is you were not willing (able?) to
understand why it makes sense to always return an array when executing
array[...]. - There are different views.

This is not the thread isnt it?

No, it's a 'Zernichter - thread'. (More about 'you', than programming)

Thanks for the confirmation, but no. I wont bore the other readers with my
boring life. I regard this list as ruby-talk , not zernichter-talk.
Changing the thread subject does not change that IMO.
U are free to come up with a separate mailing list on that topic, but just
for the record: i will not subscribe.

Why don't you respect mine? (And I'm not the only one...) - We should

discuss the pros+cons and maybe and try to convince others of the own sight.
Sad that's not possible to get a normal (technical) discussion here.

I have no problem with your view - i never criticised it. I have my own
and state it like that.

My criticism if any is about how you communicate.

Maybe it would be nicer to not offend me. You could have used other words.

This is text chat. I am not responsible for how you feel about my exact
wording.

Is that your real anser? - Everyone is responsible for what he/she is
doing...

I am responsibe for what i do,but not how u feel about it.

Ruby claim: be kind to other people! - Sure, there a other lists using
different standards.

In most words there are chances to offend ppl, because the senders context
is always different from the recievers context.

I don't think so. If you're describing (technical) things and use nice
words, that can't be offending.

Ignoring my request for more technical information is not very kind, too.

- You know which of your words I'm referring.

Again this is a text chat: decribe your context with written words rather
than vague hints. 1x1 of chatting IMO

- You are not welcome to this list, if you're not able to be kind & stay

friendly.
I read the help for ruby2.3 - this version didn't have it! (Are you
reading it all again, when updating to a new version???)

2.3? Seriously? Then why didnt u share this piece of information before?
Refering to an out-dated version of ruby is important for understanding the
test and its relevance. Claiming a bug in ruby 2.3 is different from a bug
in the latest release...

NOW I'm using a newer version, but didn't read the help again. (as
mentioned before)
- I don't think that all these details are of interesting in this list,

if you talk about performance ALL these details matter IMO: hardware,
software stack, ruby version, regexp engine. Everything matters when
comparing performance from my experience

- Are there methods, too (I don't want to see all, but only the callstack

of one specific method, as mentioned before)

I guess checking the source code for the relevant options might be useful

Yes, that's always true, but perhaps there're easier ways available...
Therefore my question.

Like is sad before: call ruby --help and read. I am sure u find a suitable
value to the --dump option for what u seem to want.

(Yes, you can always read the sourcecodes - then maybe we would not have
ANY need for this list...)

Opti

PS: Another question: did you choose your name similar to 'Vernichter'? -
Then we have to be very careful interacting with you.
If you chose your name with the intention of 'Vernichter' then we should
ban you due to this fact already.

I dont judge ppl by their names,but of course everybody is free to do
otherwise.

Because it's stated 'Der Zernichter' it looks like to be not your
real-name, but an artificial name you chose. - How did you came to that,
what's the aim to use such name? (including 'Der', = 'The
Innihilator/Wrecker')!

Of course it's not my real name. And if u did not play isometric RPGs 20-30
years ago, i cannot help u anyway

···

Die Optimisten <inform@die-optimisten.net> schrieb am Sa., 13. Aug. 2022, 11:40:

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;