Re: [fpc-pascal] Happy tickets benchmark
On 17/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: Date: Tue, 16 Feb 2016 14:44:42 +0100 From: Adrian Veith To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Happy tickets benchmark small remark for your testing series: AVG makes no sense, you should test against MIN - why ? the measured results are contaminated by other activities on your system, so the fastest result is the most accurate, because there is no way to make a program to run faster, but many ways to make it run slower. No, the test against MIN shows only the case when the result was _minimally contaminated_ in the series. But we don't know whether the unused time was bigger or smaller than for other program. Also, it is very probably that the minimal time in series of 1000 will be better that in series of 10 and so on. The average approach smooth the contaminated time in series for all programs. But you could use some better approaches like the direct measure of the time used by CPU or simply remove extreme values. I don't suppose that it changes anything in the relative comparison that is the goal of test. Regards, Serguei ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Variable Initialization Questions
Hello List, After googled and searching in the documentation, http://free-pascal-general.1045716.n5.nabble.com/does-Advanced-Record-constructor-automatically-zero-all-the-memory-space-of-that-record-td5716755.html http://www.freepascal.org/docs-html/ref/refse23.html i still have doubts about variable initialization: 1 - Does the compiler automatically initialize all class fields when a new instance is created? 2 - Does the compiler initialize record fields? 3 - When i declare a pointer as a global variable or as a member of a record, can i assume that its initial value is nil? 4 - Is there any compiler switch regarding initialization of variables? Best regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variable Initialization Questions
Mazola Winstrol wrote: 1 - Does the compiler automatically initialize all class fields when a new instance is created? They're called instance fields, and yes, they are zeroed. Class fields are fields that that are unique per class type, rather than per instance. 2 - Does the compiler initialize record fields? Only for fields that are managed types. 3 - When i declare a pointer as a global variable or as a member of a record, can i assume that its initial value is nil? No. 4 - Is there any compiler switch regarding initialization of variables? There is only -gt, but it "initialises" (non-managed) variables and out-parameter with random data in order to more easily find cases of uninitialised data. It cannot be used to initialise all variables to a known value. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variable Initialization Questions
2016-02-17 14:58 GMT-02:00 Jonas Maebe : > Mazola Winstrol wrote: > >> 1 - Does the compiler automatically initialize all class fields when a >> new instance is created? >> > > They're called instance fields, and yes, they are zeroed. Class fields are > fields that that are unique per class type, rather than per instance. > > 2 - Does the compiler initialize record fields? >> > > Only for fields that are managed types. > > 3 - When i declare a pointer as a global variable or as a member of a >> record, can i assume that its initial value is nil? >> > > No. > > 4 - Is there any compiler switch regarding initialization of variables? >> > > There is only -gt, but it "initialises" (non-managed) variables and > out-parameter with random data in order to more easily find cases of > uninitialised data. It cannot be used to initialise all variables to a > known value. > > > Jonas > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > Thanks a lot for the explanation! Regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Variable Initialization Questions
Jonas Maebe wrote: 3 - When i declare a pointer as a global variable or as a member of a record, can i assume that its initial value is nil? No. Correction: all global variables are always zeroed, so that includes pointers, records and hence also pointers in records (if those records themselves are global variables). Pointers, records or record fields in are not zeroed because they are pointers/records/record fields though (so not in case they are local variables). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Primitive Record Wrappers
Hello list, In some situations, would be very interesting to determine whether the value of a primitive variable is initialized or not. For example, fields in database records can contain null values. By implementing an ORM, it would be interesting to represent these null values in the properties of objects. Java has the so called Primitives Class Wrappers, where each primitive type (int, boolean ...) has a corresponding wrapper class (Integer, Boolean ...). By using class wrappers you can represent null values in primitive types through null class instances references. Using class wrappers in FPC is not feasible due to memory management issues (the programmer needs to worry about the lifetime of the instances and free the instances manually). Perhaps, a solution in FPC would be using primitive record wrappers with custom records operators. What do you think about it? Is there any other solution? Regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Happy tickets benchmark
On 02/17/2016 06:28 AM, Serguei TARASSOV wrote: On 17/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: small remark for your testing series: AVG makes no sense, you should test against MIN - why ? the measured results are contaminated by other activities on your system, so the fastest result is the most accurate, because there is no way to make a program to run faster, but many ways to make it run slower. No, the test against MIN shows only the case when the result was _minimally contaminated_ in the series. But we don't know whether the unused time was bigger or smaller than for other program. i thought about this, too... especially considering starting the test's binary from the command line each time and how disk caching may affect loading and unloading... Also, it is very probably that the minimal time in series of 1000 will be better that in series of 10 and so on. The average approach smooth the contaminated time in series for all programs. But you could use some better approaches like the direct measure of the time used by CPU or simply remove extreme values. one might also have the program go a little further than a simple one-time execution and have it loop internally while keeping up with the minimum, maximum and average times and output them at the end in addition to the other output in the test itself... [code below] I don't suppose that it changes anything in the relative comparison that is the goal of test. possibly not... = snip = program HappyTickets; uses SysUtils, DateUtils; var loopcnt : integer; elapsedtime, mintime, maxtime, avgtime: int64; procedure runtest; var n1, n2, n3, n4, n5, n6, n7, n8: 0..9; TicketsCount: int64; d1, d2: TDateTime; begin TicketsCount := 0; elapsedtime := 0; d1 := Now; for n1 := 0 to 9 do for n2 := 0 to 9 do for n3 := 0 to 9 do for n4 := 0 to 9 do for n5 := 0 to 9 do for n6 := 0 to 9 do for n7 := 0 to 9 do for n8 := 0 to 9 do if n1 + n2 + n3 + n4 = n5 + n6 + n7 + n8 then //if n1 + n2 + n3 + n4 - n5 - n6 - n7 in [0..9] then Inc(TicketsCount); // TicketsCount += 1; // TicketsCount := TicketsCount + 1; d2 := Now; elapsedtime := DateUtils.MilliSecondsBetween(d1, d2); writeln('Round ',loopcnt:4,' Found ', TicketsCount, ' tickets. Elapsed time, msec: ',elapsedtime ); end; begin elapsedtime := 0; mintime := 0; maxtime := 0; avgtime := 0; for loopcnt := 1 to 1000 do begin runtest; if mintime = 0 then mintime := elapsedtime; if maxtime = 0 then maxtime := elapsedtime; if avgtime = 0 then avgtime := elapsedtime else avgtime := (avgtime + elapsedtime) div 2; if elapsedtime < mintime then mintime := elapsedtime; if elapsedtime > maxtime then maxtime := elapsedtime; writeln('Min: ',mintime:5,' Max: ',maxtime:5,' Avg: ',avgtime); end; end. = snip = -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Happy tickets benchmark
I don't want to insist on this, but: if you measure the runtime of your program you result = runtime + error. If you measure a series against MIN you measure MIN(result) = runtime + MIN(error) which delivers the best value for runtime. Am 17.02.2016 um 12:28 schrieb Serguei TARASSOV: > On 17/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote: >> Date: Tue, 16 Feb 2016 14:44:42 +0100 >> From: Adrian Veith >> To: FPC-Pascal users discussions >> Subject: Re: [fpc-pascal] Happy tickets benchmark >> >> small remark for your testing series: >> AVG makes no sense, you should test against MIN - why ? the measured >> results are contaminated by other activities on your system, so the >> fastest result is the most accurate, because there is no way to make a >> program to run faster, but many ways to make it run slower. > No, the test against MIN shows only the case when the result was > _minimally contaminated_ in the series. But we don't know whether the > unused time was bigger or smaller than for other program. > Also, it is very probably that the minimal time in series of 1000 will > be better that in series of 10 and so on. > > The average approach smooth the contaminated time in series for all > programs. > But you could use some better approaches like the direct measure of > the time used by CPU or simply remove extreme values. > > I don't suppose that it changes anything in the relative comparison > that is the goal of test. > > Regards, > Serguei > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] internal error with bitpacked record in i386 with O3
(I know this is more suited for fpc-devel, but every email I sent to that list gets bounced back to me. My apologies.) I logged this mantis issue: http://mantis.freepascal.org/view.php?id=29669 Any ideas for a workaround in the meantime? I'm hoping to get a whole bunch of production code building with the new compiler and I'm hung up on this. -SG -- Seth Grover Be kind to all of your neighbors Because they're just like you. And you're nothing special Unless they are too. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal