[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to count the number of occurrences of a character in a string?
From: |
Eli Zaretskii |
Subject: |
Re: How to count the number of occurrences of a character in a string? |
Date: |
Tue, 13 Oct 2015 23:17:28 +0300 |
> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Tue, 13 Oct 2015 15:56:57 -0400
> Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
>
> Now I see some convergence in the results and this was the conclusion,
> fastest to slowest
>
> 1. cl-count
> 2. Eli's cdr approach
> 3. My string-match-p approach
>
> Code: https://gist.github.com/ab487f63727381179f61
> Raw results:
>
> 1000 executions of string-match-p approach took 0.047036 seconds
> 1000 executions of cl-count approach took 0.036476 seconds
> 1000 executions of cdr approach took 0.043735 seconds
> nil
> 1000 executions of string-match-p approach took 0.046918 seconds
> 1000 executions of cl-count approach took 0.035476 seconds
> 1000 executions of cdr approach took 0.202394 seconds
> nil
Looks like 1000 loops is too few: your measurements hit clock
quantization error, and also some background activities affect the
results. I suggest to try 10000 iterations.
Also, did you actually try 'mapc', per my second suggestion?
- Re: How to count the number of occurrences of a character in a string?, (continued)
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/12
- Re: How to count the number of occurrences of a character in a string?, Nick Dokos, 2015/10/12
- Re: How to count the number of occurrences of a character in a string?, Stefan Monnier, 2015/10/12
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?,
Eli Zaretskii <=
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Message not available
- Re: How to count the number of occurrences of a character in a string?, Brendan Halpin, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Message not available
- Re: How to count the number of occurrences of a character in a string?, Joost Kremers, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Oleh Krehel, 2015/10/14
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/14
- Re: How to count the number of occurrences of a character in a string?, Michael Heerdegen, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Charles Curley, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Noam Postavsky, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/14