Hi,
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.
It is not so small or optimized with Firefox.
It took around 100ms
With 10000000, it gives 5479ms and 4814ms, i.e. the array is faster here
With 100000000 the script does not complete, before Firefox ask "do you
want to stop the too slow script"
Like what?
What pointer code do you want to port?
I have not looked at any specific.
But recently I have started to change everything to pointers.
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.
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.
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.
Isn't that a contradiction to "port all existing"?
Not with full program static analysis
Or people could mark the values they need as pointers in other units (by
adding an unused public function just accessing it as pointer)
Best,
Benito
On 18.12.2017 17:19, Mattias Gaertner wrote:
On Mon, 18 Dec 2017 14:55:53 +0100
Benito van der Zander<ben...@benibela.de> wrote:
[...]
That would be quite a slow down.
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.
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.
Perhaps more memory usage
Pretty sure more memory usage.
Isn't speed the main idea of using pointers?
It would be to port all existing pascal code
Like what?
What pointer code do you want to port?
Also what if var and @var are in different units?
Either it needs full program static analysis, or pointers are only
allowed to something that was used with a pointer in its unit
Isn't that a contradiction to "port all existing"?
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.
That model looks like quite a slow down
The js engines have some optimizations for that model.
Mattias
_______________________________________________
fpc-devel maillist -fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel