[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How should this profiler report interpreted?
From: |
Emanuel Berg |
Subject: |
Re: How should this profiler report interpreted? |
Date: |
Fri, 26 Mar 2021 18:58:45 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
scame wrote:
>> To me it looks like it means the tool isn't up for the job
>> :) Interesting question BTW! How did you do it, exactly?
>
> I process a generated file where certain lines are connected
> by an id. I extract the id from a line, then search
> backwards for the matching line using the extracted id and
> there I insert the line after the matching line in the file.
Sounds like relational algebra, almost. To what extent can you
do that in Elisp? Need SQL? Well, obviously you can do
everything in Elisp...
> ...
> (while (looking-at "INSERT INTO `test2`.+,\\([0-9]+\\));")
> (let ((item (match-string 1))
> (line (buffer-substring (line-beginning-position)
> (line-end-position))))
> (message item)
> (save-excursion
> (re-search-backward (concat "INSERT INTO `test1`.+"
> "VALUES
> ([^,]+,'[^']*','[^']*','[^']*','[^']*',[^,]+,[^,]+,"
> item
> ","))
> (end-of-line)
> (insert "\n" line))
> (delete-region (line-beginning-position) (1+ (line-end-position)))
> )))
:) Very nice.
> This is the save-excursion which takes 99% CPU and
> very slow.
Well, these regexps in a loop - working on a huge file - which
you are modifying as you go along - is that why
`save-excursion' gets so expensive, some Gordian knot that
needs to be cut up by - Julius Caesar - Che Guevara -
Alexander the Great? - but just keeps tying itself back?
> I probably could change up the code bit, so the problem does
> not appear, but I'm curious what the problem is here. Is it
> a bug?
What happens if you try your code on a very small data file?
--
underground experts united
https://dataswamp.org/~incal
- How should this profiler report interpreted?, scame, 2021/03/26
- Re: How should this profiler report interpreted?, scame, 2021/03/26
- Re: How should this profiler report interpreted?,
Emanuel Berg <=
- Re: How should this profiler report interpreted?, Stefan Monnier, 2021/03/26
- Re: How should this profiler report interpreted?, Emanuel Berg, 2021/03/26
- Re: How should this profiler report interpreted?, Stefan Monnier, 2021/03/26
- Re: How should this profiler report interpreted?, Emanuel Berg, 2021/03/26
- Re: How should this profiler report interpreted?, Emanuel Berg, 2021/03/27
- Re: How should this profiler report interpreted?, Emanuel Berg, 2021/03/27
Re: How should this profiler report interpreted?, scame, 2021/03/26
Re: How should this profiler report interpreted?, scame, 2021/03/26