all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* point-at-final-line
@ 2018-01-27  1:14 Emanuel Berg
  2018-01-27  1:36 ` point-at-final-line Ben Bacarisse
  0 siblings, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2018-01-27  1:14 UTC (permalink / raw)
  To: help-gnu-emacs

Did anyone do

(defun point-at-final-line ()
  (let ((line (line-number-at-pos)))
    (save-excursion
      (forward-line 1)
      (= line (line-number-at-pos)) )))

?

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-27  1:14 point-at-final-line Emanuel Berg
@ 2018-01-27  1:36 ` Ben Bacarisse
  2018-01-27  1:52   ` point-at-final-line John Mastro
                     ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ben Bacarisse @ 2018-01-27  1:36 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <moasen@zoho.com> writes:

> Did anyone do
>
> (defun point-at-final-line ()
>   (let ((line (line-number-at-pos)))
>     (save-excursion
>       (forward-line 1)
>       (= line (line-number-at-pos)) )))
>
> ?

Maybe something like

  (= (line-number-at-pos) (line-number-at-pos (point-max)))

though the details depend on how you interpret the final line.

-- 
Ben.


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

* Re: point-at-final-line
  2018-01-27  1:36 ` point-at-final-line Ben Bacarisse
@ 2018-01-27  1:52   ` John Mastro
  2018-01-27  2:50   ` point-at-final-line Emanuel Berg
       [not found]   ` <mailman.8058.1517017989.27995.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 19+ messages in thread
From: John Mastro @ 2018-01-27  1:52 UTC (permalink / raw)
  To: help-gnu-emacs

Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
> Emanuel Berg <moasen@zoho.com> writes:
> > Did anyone do
> >
> > (defun point-at-final-line ()
> >   (let ((line (line-number-at-pos)))
> >     (save-excursion
> >       (forward-line 1)
> >       (= line (line-number-at-pos)) )))
> >
> > ?
>
> Maybe something like
>
>   (= (line-number-at-pos) (line-number-at-pos (point-max)))
>
> though the details depend on how you interpret the final line.

This should do it too, without needing line-number-at-pos:

(defun point-at-final-line ()
  (save-excursion
    (end-of-line)
    (= (forward-line 1) 1)))

Since forward-line returns "the count of lines left to move".

The end-of-line call is because of this bit, from the docstring:

    Exception: With positive N, a non-empty line at the end of the
    buffer, or of its accessible portion, counts as one line
    successfully moved (for the return value). This means that the
    function will move point to the end of such a line and will count it
    as a line moved across, even though there is no next line to go to
    its beginning.

It seems ambiguous to me whether (based on that description) moving to
the end of the line should get us the result we're looking for, but it
seems to in practice. You could use (or (eobp) (= (forward-line 1) 1))
to be safe.

        John



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

* Re: point-at-final-line
  2018-01-27  1:36 ` point-at-final-line Ben Bacarisse
  2018-01-27  1:52   ` point-at-final-line John Mastro
@ 2018-01-27  2:50   ` Emanuel Berg
       [not found]   ` <mailman.8058.1517017989.27995.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-27  2:50 UTC (permalink / raw)
  To: help-gnu-emacs

Ben Bacarisse wrote:

>> Did anyone do
>> (defun point-at-final-line () (let ((line (line-number-at-pos))) (save-excursion (forward-line 1) (= line (line-number-at-pos)) )))
>> ?
>
> Maybe something like
>
>   (= (line-number-at-pos) (line-number-at-pos
> (point-max)))
>
> though the details depend on how you
> interpret the final line.

No, that's much better, thank you.

No one ever did this since 1976, ey? In a while
I'll show you the use case but I can tell you
right now it isn't anything radical to motivate
the delay...

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
       [not found]   ` <mailman.8058.1517017989.27995.help-gnu-emacs@gnu.org>
@ 2018-01-27  2:56     ` Emanuel Berg
  2018-01-27  3:02     ` point-at-final-line Emanuel Berg
  1 sibling, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-27  2:56 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro wrote:

> This should do it too, without needing
> line-number-at-pos

Right, what is better to not have?
`line-number-at-pos' or `save-excursion'?
Normally, I'd say `save-excursion' is better to
not have than most other functions. But here,
`line-number-at-pos' is implemented with
`save-excursion'! But at least it doesn't
show...

> (defun point-at-final-line ()
>  (save-excursion
>    (end-of-line)
>    (= (forward-line 1) 1)))
>
> Since forward-line returns "the count of
> lines left to move".

Indeed, I thought about it this, but the code
sure looks cryptic, especially for such
a trivial task. Again, this won't show when
"point-at-final-line" is called!

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
       [not found]   ` <mailman.8058.1517017989.27995.help-gnu-emacs@gnu.org>
  2018-01-27  2:56     ` point-at-final-line Emanuel Berg
@ 2018-01-27  3:02     ` Emanuel Berg
  2018-01-27  6:11       ` point-at-final-line Marcin Borkowski
                         ` (5 more replies)
  1 sibling, 6 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-27  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

Seems to be virtually no difference
in performance.

So I'll go with the best-looking code, which is
"point-at-final-line".

Unless there are new facts to the case brought
to the courts attention...

(defmacro measure-time (&rest body)
  "Measure and return the running time of the code block.
Not mine: http://nullprogram.com/blog/2009/05/28/"
  (declare (indent defun))
  (let ((start (make-symbol "start")))
    `(let ((,start (float-time)))
       ,@body
       (- (float-time) ,start))))

(defun point-at-final-line ()
  (= (line-number-at-pos)
     (line-number-at-pos (point-max)) ))
;; (insert (format "\n;; %f" (measure-time #'point-at-final-line)))
;; 0.000005

(defun point-at-final-line-2 ()
  (save-excursion
    (end-of-line)
    (= 1 (forward-line 1)) ))
;; (insert (format "\n;; %f" (measure-time #'point-at-final-line-2)))
;; 0.000006

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-27  3:02     ` point-at-final-line Emanuel Berg
@ 2018-01-27  6:11       ` Marcin Borkowski
       [not found]       ` <mailman.8063.1517033499.27995.help-gnu-emacs@gnu.org>
                         ` (4 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Marcin Borkowski @ 2018-01-27  6:11 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


On 2018-01-27, at 04:02, Emanuel Berg <moasen@zoho.com> wrote:

> (defmacro measure-time (&rest body)
>   "Measure and return the running time of the code block.
> Not mine: http://nullprogram.com/blog/2009/05/28/"
>   (declare (indent defun))
>   (let ((start (make-symbol "start")))
>     `(let ((,start (float-time)))
>        ,@body
>        (- (float-time) ,start))))

Why not use benchmark.el?

Best,

-- 
Marcin Borkowski



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

* Re: point-at-final-line
       [not found]       ` <mailman.8063.1517033499.27995.help-gnu-emacs@gnu.org>
@ 2018-01-27  7:05         ` Emanuel Berg
  0 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-27  7:05 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski wrote:

>> (defmacro measure-time (&rest body) "Measure
>> and return the running time of the code
>> block. Not mine:
>> http://nullprogram.com/blog/2009/05/28/"
>> (declare (indent defun)) (let ((start
>> (make-symbol "start"))) `(let ((,start
>> (float-time))) ,@body (- (float-time)
>> ,start))))
>
> Why not use benchmark.el?

My bench has enough marks as it is.
My favorite is when I carved "NO FATE" while
watching Terminator 2. Actually everything
I ever learned how it works socially in life
I got from that movie.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-27  3:02     ` point-at-final-line Emanuel Berg
  2018-01-27  6:11       ` point-at-final-line Marcin Borkowski
       [not found]       ` <mailman.8063.1517033499.27995.help-gnu-emacs@gnu.org>
@ 2018-01-28 16:06       ` Stefan Monnier
       [not found]       ` <mailman.8116.1517155644.27995.help-gnu-emacs@gnu.org>
                         ` (2 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2018-01-28 16:06 UTC (permalink / raw)
  To: help-gnu-emacs

> Seems to be virtually no difference
> in performance.

Try them in a very large buffer.


        Stefan




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

* Re: point-at-final-line
       [not found]       ` <mailman.8116.1517155644.27995.help-gnu-emacs@gnu.org>
@ 2018-01-28 18:59         ` Emanuel Berg
  2018-01-28 20:36           ` point-at-final-line Eli Zaretskii
       [not found]           ` <mailman.8132.1517171769.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-28 18:59 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> Seems to be virtually no difference
>> in performance.
>
> Try them in a very large buffer.

How large is very large? I wrote the below zsh
to create large files that look like this:

    1f6920fd18f25904026c59ee560f53c815dde2f854e21e40ceb3f3d58fa55ab9
    593bc90bcecd16dada33273deb2a79e593703844ccc65a2139928124357c7755
    d43d005aeb2bd1b68e264918f99e41aa175b7a9354a171631db0038c68c59f46
    09eab885d64735c3fcd49d650cf1d237025faf9e40ae356017c07fab9db2005c

With 10 000 lines there was still no
difference. With 100 000 lines and a file size
of 6.2M, the results were... identical.

create-bogus-file () {
    local file=$1
    local lines=$2
    rm -r $file
    for l in {0..$lines}; do
        dd if=/dev/urandom count=1 2> /dev/null |
            sha256sum |
            ( read rnd _; echo $rnd >> $file )
    done
}

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-28 18:59         ` point-at-final-line Emanuel Berg
@ 2018-01-28 20:36           ` Eli Zaretskii
       [not found]           ` <mailman.8132.1517171769.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2018-01-28 20:36 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Emanuel Berg <moasen@zoho.com>
> Date: Sun, 28 Jan 2018 19:59:14 +0100
> 
> Stefan Monnier wrote:
> 
> >> Seems to be virtually no difference
> >> in performance.
> >
> > Try them in a very large buffer.
> 
> How large is very large? I wrote the below zsh
> to create large files that look like this:
> 
>     1f6920fd18f25904026c59ee560f53c815dde2f854e21e40ceb3f3d58fa55ab9
>     593bc90bcecd16dada33273deb2a79e593703844ccc65a2139928124357c7755
>     d43d005aeb2bd1b68e264918f99e41aa175b7a9354a171631db0038c68c59f46
>     09eab885d64735c3fcd49d650cf1d237025faf9e40ae356017c07fab9db2005c
> 
> With 10 000 lines there was still no
> difference. With 100 000 lines and a file size
> of 6.2M, the results were... identical.

Yes, counting lines is fast.  But not counting lines is even faster.

You don't need to compute the number of the current line, you just
need to establish whether the line current ends at EOB.  Right?  And
the line's end is given by line-end-position, right?



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

* Re: point-at-final-line
       [not found]           ` <mailman.8132.1517171769.27995.help-gnu-emacs@gnu.org>
@ 2018-01-29 15:03             ` Emanuel Berg
  2018-01-29 16:04               ` point-at-final-line Eli Zaretskii
       [not found]               ` <mailman.8177.1517241890.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-29 15:03 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:

> Yes, counting lines is fast. But not counting
> lines is even faster.
>
> You don't need to compute the number of the
> current line, you just need to establish
> whether the line current ends at EOB. Right?
> And the line's end is given by
> line-end-position, right?

If you mean like this

(defun point-at-final-line-3 ()
  (= (line-end-position) (point-max)) )

I agree it looks the best thus far, however
with 100 000 lines it is still 0.000005 just
like the others. Anyone else feel free to
create an even bigger file

create-bogus-file () {
    local file=$1
    local lines=$2
    rm -r $file
    for l in {0..$lines}; do
        dd if=/dev/urandom count=1 2> /dev/null |
            sha256sum |
            ( read rnd _; echo $rnd >> $file )
    done
}
alias cbf=create-bogus-file

(defmacro measure-time (&rest body)
  "Measure and return the running time of the code block.
Not mine: http://nullprogram.com/blog/2009/05/28/"
  (declare (indent defun))
  (let ((start (make-symbol "start")))
    `(let ((,start (float-time)))
       ,@body
       (- (float-time) ,start))))

(defun point-at-final-line ()
  (= (line-number-at-pos)
     (line-number-at-pos (point-max)) ))
;; (insert (format "\n;; %f" (measure-time #'point-at-final-line)))
;; 0.000005

(defun point-at-final-line-2 ()
  (save-excursion
    (end-of-line) (= 1 (forward-line 1)) ))
;; (insert (format "\n;; %f" (measure-time #'point-at-final-line-2)))
;; 0.000006

(defun point-at-final-line-3 ()
  (= (line-end-position) (point-max)) )
;; (insert (format "\n;; %f" (measure-time #'point-at-final-line-3)))
;; 0.000006

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-29 15:03             ` point-at-final-line Emanuel Berg
@ 2018-01-29 16:04               ` Eli Zaretskii
       [not found]               ` <mailman.8177.1517241890.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2018-01-29 16:04 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Emanuel Berg <moasen@zoho.com>
> Date: Mon, 29 Jan 2018 16:03:10 +0100
> 
> Eli Zaretskii wrote:
> 
> > Yes, counting lines is fast. But not counting
> > lines is even faster.
> >
> > You don't need to compute the number of the
> > current line, you just need to establish
> > whether the line current ends at EOB. Right?
> > And the line's end is given by
> > line-end-position, right?
> 
> If you mean like this
> 
> (defun point-at-final-line-3 ()
>   (= (line-end-position) (point-max)) )
> 
> I agree it looks the best thus far, however
> with 100 000 lines it is still 0.000005 just
> like the others.

Good engineering which leads to elegant solutions should be preferable
even when it has no tangible performance advantages.

(But I'm sure that if you run each function many times in a loop, you
will see some differences in timing.  Right now, I think the times are
below your system clock resolution, so you are measuring quantization
noise.)



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

* Re: point-at-final-line
       [not found]               ` <mailman.8177.1517241890.27995.help-gnu-emacs@gnu.org>
@ 2018-01-29 16:40                 ` Emanuel Berg
  2018-01-29 17:51                   ` point-at-final-line Eli Zaretskii
       [not found]                   ` <mailman.8185.1517248285.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-29 16:40 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:

> (But I'm sure that if you run each function
> many times in a loop, you will see some
> differences in timing. Right now, I think the
> times are below your system clock resolution,
> so you are measuring quantization noise.)

Well, you know what they say, what you can't
measure, you cannot control. That is why the
Americans keep track of what NHL defenseman has
scored the most shorthanded goals in the third
period while not having the home field
advantage...

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-29 16:40                 ` point-at-final-line Emanuel Berg
@ 2018-01-29 17:51                   ` Eli Zaretskii
       [not found]                   ` <mailman.8185.1517248285.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2018-01-29 17:51 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Emanuel Berg <moasen@zoho.com>
> Date: Mon, 29 Jan 2018 17:40:38 +0100
> 
> Eli Zaretskii wrote:
> 
> > (But I'm sure that if you run each function
> > many times in a loop, you will see some
> > differences in timing. Right now, I think the
> > times are below your system clock resolution,
> > so you are measuring quantization noise.)
> 
> Well, you know what they say, what you can't
> measure, you cannot control.

I'm saying that you _can_ measure this: just run each function many
times in a loop, and then divide the time by the number of iterations.
This is a standard method of timing short code fragments.



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

* Re: point-at-final-line
       [not found]                   ` <mailman.8185.1517248285.27995.help-gnu-emacs@gnu.org>
@ 2018-01-30  2:18                     ` Emanuel Berg
  2018-01-30  3:32                       ` point-at-final-line Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2018-01-30  2:18 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii wrote:

> I'm saying that you _can_ measure this: just
> run each function many times in a loop, and
> then divide the time by the number of
> iterations. This is a standard method of
> timing short code fragments.

I don't know about that method. The reason is
it seems to favor your suggestion. And not by
a little! Here are the results in seconds for
10 000 runs in a buffer of 55 lines:

    ;; point-at-final-line-3   0.08
    ;; point-at-final-line-2   0.38
    ;; point-at-final-line-1   0.55

The entire code yanked:

;; This file: http://user.it.uu.se/~embe8573/emacs-init/measure.el

(require 'cl-lib)

(defun point-at-final-line-1 ()
  (= (line-number-at-pos)
     (line-number-at-pos (point-max) )))

(defun point-at-final-line-2 ()
  (save-excursion
    (end-of-line) (= 1 (forward-line 1)) ))

(defun point-at-final-line-3 ()
  (= (line-end-position) (point-max)) )

(defmacro measure-time (&rest body)
  "Measure and return the running time of the code block.
Not mine: http://nullprogram.com/blog/2009/05/28/"
  (declare (indent defun))
  (let ((start (make-symbol "start")))
    `(let ((,start (float-time)))
       ,@body
       (- (float-time) ,start))))

(defun create-random-list (max len)
  (let ((l ()))
    (cl-loop repeat len do
      (push (random max) l))
    l) )

(defun test-final-line-f (fun pos-list)
  (cl-loop for p in pos-list do
    (goto-char p)
    (apply fun nil) ))

(defun test-final-line (its)
  (let*((max      (point-max))
        (pos-list (create-random-list max its))
        (funs     (list #'point-at-final-line-1
                        #'point-at-final-line-2
                        #'point-at-final-line-3) )
        (times    ()) )
    (cl-loop for f in funs do
      (push (list f (measure-time (test-final-line-f f pos-list))) times) )
    (goto-char (point-max))
    (let ((sorted-times (cl-sort times #'< :key #'cadr)))
      (cl-loop for time in sorted-times do
        (insert (format "\n;; %s   %0.2f" (car time) (cadr time)))
        ))))
;; (test-final-line 10000)

;; point-at-final-line-3   0.08
;; point-at-final-line-2   0.38
;; point-at-final-line-1   0.55

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: point-at-final-line
  2018-01-30  2:18                     ` point-at-final-line Emanuel Berg
@ 2018-01-30  3:32                       ` Eli Zaretskii
  0 siblings, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2018-01-30  3:32 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Emanuel Berg <moasen@zoho.com>
> Date: Tue, 30 Jan 2018 03:18:18 +0100
> 
> I don't know about that method. The reason is
> it seems to favor your suggestion. And not by
> a little! Here are the results in seconds for
> 10 000 runs in a buffer of 55 lines:
> 
>     ;; point-at-final-line-3   0.08
>     ;; point-at-final-line-2   0.38
>     ;; point-at-final-line-1   0.55

That's expected, but you should also make sure none of the methods
does some caching behind the scenes, because if some do, the cache
needs to be disabled or flushed between iterations.



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

* Re: point-at-final-line
  2018-01-27  3:02     ` point-at-final-line Emanuel Berg
                         ` (3 preceding siblings ...)
       [not found]       ` <mailman.8116.1517155644.27995.help-gnu-emacs@gnu.org>
@ 2018-01-30  3:50       ` Stefan Monnier
       [not found]       ` <mailman.8212.1517284260.27995.help-gnu-emacs@gnu.org>
  5 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2018-01-30  3:50 UTC (permalink / raw)
  To: help-gnu-emacs

> (defmacro measure-time (&rest body)
>   "Measure and return the running time of the code block.
> Not mine: http://nullprogram.com/blog/2009/05/28/"
>   (declare (indent defun))
>   (let ((start (make-symbol "start")))
>     `(let ((,start (float-time)))
>        ,@body
>        (- (float-time) ,start))))
[...]
> ;; (insert (format "\n;; %f" (measure-time #'point-at-final-line)))

This doesn't actually call the function, so no wonder it will take the
same amount of time no matter which function you pass to it.


        Stefan




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

* Re: point-at-final-line
       [not found]       ` <mailman.8212.1517284260.27995.help-gnu-emacs@gnu.org>
@ 2018-01-30 14:52         ` Emanuel Berg
  0 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2018-01-30 14:52 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> (insert (format "\n;; %f" (measure-time
>> #'point-at-final-line)))
>
> This doesn't actually call the function, so
> no wonder it will take the same amount of
> time no matter which function you pass to it.

And if you do it the right way, you don't need
a buffer of 100 000 lines or 10 000 iterations:

;; (insert (format "\n;; %f" (measure-time (point-at-final-line-1))))
;; 0.000154
;; (insert (format "\n;; %f" (measure-time (point-at-final-line-2))))
;; 0.000045
;; (insert (format "\n;; %f" (measure-time (point-at-final-line-3))))
;; 0.000014

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

end of thread, other threads:[~2018-01-30 14:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-27  1:14 point-at-final-line Emanuel Berg
2018-01-27  1:36 ` point-at-final-line Ben Bacarisse
2018-01-27  1:52   ` point-at-final-line John Mastro
2018-01-27  2:50   ` point-at-final-line Emanuel Berg
     [not found]   ` <mailman.8058.1517017989.27995.help-gnu-emacs@gnu.org>
2018-01-27  2:56     ` point-at-final-line Emanuel Berg
2018-01-27  3:02     ` point-at-final-line Emanuel Berg
2018-01-27  6:11       ` point-at-final-line Marcin Borkowski
     [not found]       ` <mailman.8063.1517033499.27995.help-gnu-emacs@gnu.org>
2018-01-27  7:05         ` point-at-final-line Emanuel Berg
2018-01-28 16:06       ` point-at-final-line Stefan Monnier
     [not found]       ` <mailman.8116.1517155644.27995.help-gnu-emacs@gnu.org>
2018-01-28 18:59         ` point-at-final-line Emanuel Berg
2018-01-28 20:36           ` point-at-final-line Eli Zaretskii
     [not found]           ` <mailman.8132.1517171769.27995.help-gnu-emacs@gnu.org>
2018-01-29 15:03             ` point-at-final-line Emanuel Berg
2018-01-29 16:04               ` point-at-final-line Eli Zaretskii
     [not found]               ` <mailman.8177.1517241890.27995.help-gnu-emacs@gnu.org>
2018-01-29 16:40                 ` point-at-final-line Emanuel Berg
2018-01-29 17:51                   ` point-at-final-line Eli Zaretskii
     [not found]                   ` <mailman.8185.1517248285.27995.help-gnu-emacs@gnu.org>
2018-01-30  2:18                     ` point-at-final-line Emanuel Berg
2018-01-30  3:32                       ` point-at-final-line Eli Zaretskii
2018-01-30  3:50       ` point-at-final-line Stefan Monnier
     [not found]       ` <mailman.8212.1517284260.27995.help-gnu-emacs@gnu.org>
2018-01-30 14:52         ` point-at-final-line Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.