[fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
Hi All, I am programming a Bloom Filter and need a high-performance way to allocate and wipe large block of memory. I did the following test: program getmem; {$mode objfpc}{$H+} uses epiktimer; const SIZE = 1024 * 1024 * 1024; CNT = 10; var a: array of Byte; p: Pointer; et: TEpikTimer;

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory: Alloc: 2.8100E-0005 Clear: 7.74975504E-0001 ___ fpc-pascal

[fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
Hi, Is it possible to do Cocoa GUI programming on Mac/OSX using FreePascal but without objective-pascal mode/dialect? Just pure object pascal or delphi mode. How do I access the Cocoa SDK (foundation, appkit, etc) from pascal code? GUI programming without GUI IDE is fine with me as long as I could

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Jonas Maebe
On 02/11/14 15:43, Bee wrote: > "I'm an old pascal lover who feels left alone on Apple platform because > FreePascal/Lazarus are no longer Apple friendly like they used to be." How was FPC more "Apple friendly" in the past than it is now? Jonas ___ fpc

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
Minggu, 02 November 2014, Jonas Maebe menulis: On 02/11/14 15:43, Bee wrote: > > "I'm an old pascal lover who feels left alone on Apple platform because > > FreePascal/Lazarus are no longer Apple friendly like they used to be." > > How was FPC more "Apple friendly" in the past than it is now? D

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Jonas Maebe
On 02/11/14 16:37, Bee wrote: > > Minggu, 02 November 2014, Jonas Maebe > menulis: > > On 02/11/14 15:43, Bee wrote: > > "I'm an old pascal lover who feels left alone on Apple platform > because > > FreePascal/Lazarus are no longer Apple friendly

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Felipe Monteiro de Carvalho
On Sun, Nov 2, 2014 at 3:43 PM, Bee wrote: > Is it possible to do Cocoa GUI programming on Mac/OSX using FreePascal but > without objective-pascal mode/dialect? Just pure object pascal or delphi > mode. How do I access the Cocoa SDK (foundation, appkit, etc) from pascal > code? It is possible, I

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
Am 02.11.2014 14:55 schrieb "Xiangrong Fang" : > > Hi All, > > I am programming a Bloom Filter and need a high-performance way to allocate and wipe large block of memory. I did the following test: > > program getmem; > {$mode objfpc}{$H+} > uses epiktimer; > const > SIZE = 1024 * 1024 * 1024; >

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Sven Barth
Am 02.11.2014 15:44 schrieb "Bee" : > It is also breaks one of the most important advantage of FreePascal: cross platform language. How will you be cross platform if you access Cocoa directly? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.f

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Constantine Yannakopoulos
On Sun, Nov 2, 2014 at 3:54 PM, Xiangrong Fang wrote: > Also, I usually use pointer to pass block of memory to functions. How do > I implement a function with the following signature: > > procedure MyProc(var Buf; Len: Integer): > > I mean, how to handle "var Buf" inside the procedure body? > U

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 2:50 GMT+08:00 Sven Barth : > If you use SetLength the dynamic array consists not only of the array > data, but also of an information record in front of it. This will likely > lead to the data not being aligned correctly (FillQWord works best with > 8-Byte alignment). So what about tes

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
On Mon, Nov 3, 2014 at 12:28 AM, Jonas Maebe wrote: > > I assume you didn't put it there in the hope that nobody would ever > notice it or ask questions about it. If you did in fact hope that, then > there are probably more effective approaches than posting it to the > fpc-pascal mailing list, w

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Dmitry Boyarintsev
On Sun, Nov 2, 2014 at 10:10 PM, Bee wrote: > > Take a look at Delphi. From a single source code base, we can compile it > for Windows and Mac. Hardly any changes are required. But if you want to > target Mac using FPC, I believe you have to use objective-pascal to access > Cocoa API which is not

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
On 03.11.2014 02:59, Xiangrong Fang wrote: 2014-11-03 2:50 GMT+08:00 Sven Barth mailto:pascaldra...@googlemail.com>>: If you use SetLength the dynamic array consists not only of the array data, but also of an information record in front of it. This will likely lead to the data not be

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Sven Barth
On 03.11.2014 04:10, Bee wrote: On Mon, Nov 3, 2014 at 1:52 AM, Sven Barth mailto:pascaldra...@googlemail.com>> wrote: How will you be cross platform if you access Cocoa directly? Take a look at Delphi. From a single source code base, we can compile it for Windows and Mac. Hardly any change

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nikolay Nikolov
On 11/02/2014 03:54 PM, Xiangrong Fang wrote: Hi All, ... Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature: procedure MyProc(var Buf; Len: Integer): I mean, how to handle "var Buf" inside the procedure body? You c

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nico Erfurth
On 02.11.14 15:05, Xiangrong Fang wrote: > Sorry, the results in previous mail was mis-labeled. > > ​ > The result is: > > Using SetLength: > > Alloc: 9.40781697E-0001 > Clear: 2.13420202E-0001 > > Using GetMemory: > > Alloc: 2.8100E-0005 > Clear: 7.74975500

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 14:39 GMT+08:00 Sven Barth : > > Would you mind to show the timings that you got for FillChar? :) ​Using FillChar is always about 5% (or less) faster than FillQWord when used with GetMemory, but will be around 20%-40% faster if the memory is allocated by SetLength. Additionally this