<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
<div id="smartTemplate4-template"><br>
Hi,<br>
<br>
<p> </p>
<blockquote type="cite">
<pre wrap="">Of course not. First of all 100000 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 100000000 iterations you get 1.1s and 1.9s.</pre>
</blockquote>
<p>It is not so small or optimized with Firefox. <br>
</p>
<p>It took around 100ms<br>
</p>
With 10000000, it gives 5479ms and 4814ms, i.e. the array is
faster here<br>
<br>
With 100000000 the script does not complete, before Firefox ask
"do you want to stop the too slow script"<br>
<br>
<blockquote type="cite">
<pre wrap="">Like what?
What pointer code do you want to port?
</pre>
</blockquote>
<br>
I have not looked at any specific. <br>
<br>
But recently I have started to change everything to pointers.<br>
<br>
For example when you have an array and want a subrange without the
first element of the array, you can either copy almost everything
in a new array, or just use a pointer to the second element.<br>
<br>
Or in my XQuery interpreter I used interfaces to get ref counting,
but at many places the ref counting was too slow, so I replaced it
with pointers to interfaces. <br>
<br>
E.g. when iterating over an array of interfaces with an
enumerator. for x in thearray do, the array keeps the ref count
>= 1, so x is much more efficient as pointer to an interface. <br>
<br>
<br>
<br>
<blockquote type="cite">
<pre wrap="">Isn't that a contradiction to "port all existing"?
</pre>
</blockquote>
<br>
Not with full program static analysis<br>
<br>
Or people could mark the values they need as pointers in other
units (by adding an unused public function just accessing it as
pointer)<br>
<br>
Best,<br>
Benito </div>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 18.12.2017 17:19, Mattias Gaertner
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20171218171921.58e91f3c@limapholos.matflo.wg">
<pre wrap="">On Mon, 18 Dec 2017 14:55:53 +0100
Benito van der Zander <a class="moz-txt-link-rfc2396E" href="mailto:benito@benibela.de"><benito@benibela.de></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">[...]
</pre>
<blockquote type="cite">
<pre wrap="">That would be quite a slow down.
</pre>
</blockquote>
<pre wrap="">Is it?
I saw no speed difference between
var x = 1;
for (var i=0;i<100000;i++) x++;
and
var x = [1];
for (var i=0;i<100000;i++) x[0]++;
in Firefox.
</pre>
</blockquote>
<pre wrap="">Of course not. First of all 100000 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 100000000 iterations you get 1.1s and 1.9s.
Test with some more real world code.
</pre>
<blockquote type="cite">
<pre wrap="">Perhaps more memory usage
</pre>
</blockquote>
<pre wrap="">Pretty sure more memory usage.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Isn't speed the main idea of using pointers?
</pre>
</blockquote>
<pre wrap="">It would be to port all existing pascal code
</pre>
</blockquote>
<pre wrap="">Like what?
What pointer code do you want to port?
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Also what if var and @var are in different units?
</pre>
</blockquote>
<pre wrap="">Either it needs full program static analysis, or pointers are only
allowed to something that was used with a pointer in its unit
</pre>
</blockquote>
<pre wrap="">Isn't that a contradiction to "port all existing"?
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.
</pre>
</blockquote>
<pre wrap="">That model looks like quite a slow down
</pre>
</blockquote>
<pre wrap="">The js engines have some optimizations for that model.
Mattias
_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>