From: Müller G. <glo...@st...> - 2008-08-05 14:27:30
Attachments:
bug_report_1_short.e
|
Hi all I found a way to make gec produce this: feiffel1.c: In function T22c1: feiffel1.c:272: warning: assignment makes integer from pointer without a cast To do this you create a class with a generic parameter e.g. like this: class BUG_REPORT_1_SHORT[G] create make feature -- Initialization make(first_item: G) is local tmp: INTEGER_64 do tmp ?= first_item end end -- class Then you call make from another class, e.g. like this: local i: INTEGER sw: BUG_REPORT_1_SHORT[INTEGER] do create sw.make(1) end Kind regards, Gloria PS: Something unrelated. I wanted to time my code. Is it really that Eiffel can only measure time up to a precision of seconds? If I want to time my code I need at least nanoseconds. Any idea how to do this? Using command line "time" is inconvenient. I want to measure time of little code pieces not of the entire app. |
From: Eric B. <er...@go...> - 2008-08-06 10:04:47
|
Hi Gloria, Müller Gloria wrote: > I found a way to make gec produce this: > > feiffel1.c: In function ‘T22c1’: > feiffel1.c:272: warning: assignment makes integer from pointer without a cast > > > To do this you create a class with a generic parameter e.g. like this: > > > class > BUG_REPORT_1_SHORT[G] > > create > make > > feature -- Initialization > > make(first_item: G) is > local > tmp: INTEGER_64 > do > tmp ?= first_item > end > > end -- class > > > Then you call make from another class, e.g. like this: > > > local > i: INTEGER > sw: BUG_REPORT_1_SHORT[INTEGER] > do > create sw.make(1) > end I now fixed it in the version in SVN to have the same behavior as ISE, and the C compilation warning should be fixed as well. The problem was that this code should have been flagged with a VJRV validity error according to ETL2 (this construct does not exist anymore in ECMA Eiffel, replaced by object-tests) because the target is expanded. I had removed this validity error checking in Gobo because ISE also removed it a while ago, but I had forgotten to update the code generation. However note that the behavior in ISE (and now in Gobo) may be weird at first. In your example, if I remplace the routine `make' by: ~~~~~~~~~~~~~~~~~~~~ make(first_item: G) is local tmp: INTEGER_64 do tmp := 2 tmp ?= first_item print (tmp) end ~~~~~~~~~~~~~~~~~~~~ the program will print 2, and not 1 or 0. It's because ISE does not change the value of the target when the assignment attempt fails. Note that it would have made more sense to set the target to its default value in that case (which would be 0 for INTEGER_64) in order to have a behavior similar to the case of reference types where the target is set to Void (which is nothing else than the default value of reference types). > Something unrelated. I wanted to time my code. Is it really that Eiffel can only measure > time up to a precision of seconds? If I want to time my code I need at least nanoseconds. > Any idea how to do this? Using command line "time" is inconvenient. I want to measure > time of little code pieces not of the entire app. You would have to find an Eiffel date/time library which supports nanoseconds, or write one if one does not exist yet. The Gobo date/time library is indeed limited to milliseconds. You may have a look at ISE's EiffelTime library, but I think that it has the same limitation when calling `make_now'. -- Eric Bezault mailto:er...@go... http://www.gobosoft.com |
From: Paul C. <pa...@se...> - 2008-08-06 10:48:35
|
Hi, On Wed, Aug 6, 2008 at 12:03 PM, Eric Bezault <er...@go...> wrote: > Müller Gloria wrote: >> Something unrelated. I wanted to time my code. Is it really that Eiffel can only measure >> time up to a precision of seconds? If I want to time my code I need at least nanoseconds. >> Any idea how to do this? Using command line "time" is inconvenient. I want to measure >> time of little code pieces not of the entire app. > > You would have to find an Eiffel date/time library which supports > nanoseconds, or write one if one does not exist yet. The Gobo > date/time library is indeed limited to milliseconds. You may have > a look at ISE's EiffelTime library, but I think that it has the same > limitation when calling `make_now'. High precision timing is very dependent on the hardware and operating system you are using. Millisecond resolution should be good enough for most non-embedded situations. On Linux you could try wrapping the High Precision Event Timer (HPET) and you could maybe achieve nanoseconds resolution. I'm not sure. See: http://en.wikipedia.org/wiki/High_Precision_Event_Timer See here for an example C program using HPET: http://www.mjmwired.net/kernel/Documentation/hpet.txt If you do wrap HPET I would be glad to use it! ;-) /Paul -- Paul Cohen mobile: +46 730 787 035 e-mail: pau...@se... |
From: Müller G. <glo...@st...> - 2008-08-06 11:13:55
Attachments:
stop_watch.e
|
Hi, Thanks for the quick answer! I have already written something (see the attachment). It does nanoseconds, at least on mac. I'd be interested if it also works on Linux. I assume it should. > If you do wrap HPET I would be glad to use it! ;-) Is this of any use to you? Kind regards, Gloria |
From: Eric B. <er...@go...> - 2008-08-06 12:44:45
|
Forwarded to the list. Müller Gloria wrote: > Hi Eric > > > ~~~~~~~~~~~~~~~~~~~~ > make(first_item: G) is > local > tmp: INTEGER_64 > do > tmp := 2 > tmp ?= first_item > print (tmp) > end > ~~~~~~~~~~~~~~~~~~~~ > >> the program will print 2, and not 1 or 0. It's because ISE does not >> change the value of the target when the assignment attempt fails. > But in my example the assignment shoudln't fail because G is INTEGER_32. > > But never mind ISE I don't use it. I can't fiddle around with something that > constantly crashes because of "internal errors". > Gobo has "internal errors" too. But at least gobo doesn't crash so it doesn't > bother me. > >> You would have to find an Eiffel date/time library which supports >> nanoseconds, or write one if one does not exist yet. The Gobo > Yes I was wondering whether anyone knows of an existing one. > I have already written something. It's not a library though but it > does what I need. > > > Kind regards, > > Gloria > |
From: Eric B. <er...@go...> - 2008-08-06 12:48:40
|
Forwarded to the list. Eric Bezault wrote: > Müller Gloria wrote: >> ~~~~~~~~~~~~~~~~~~~~ >> make(first_item: G) is >> local >> tmp: INTEGER_64 >> do >> tmp := 2 >> tmp ?= first_item >> print (tmp) >> end >> ~~~~~~~~~~~~~~~~~~~~ >> >>> the program will print 2, and not 1 or 0. It's because ISE does not >>> change the value of the target when the assignment attempt fails. >> But in my example the assignment shoudln't fail because G is INTEGER_32. > > INTEGER_32 does not conform to INTEGER_64, so the assignment > attempt fails. There is no conversion involved in assignment > attempts, so the fact that INTEGER_32 converts to INTEGER_64 > does not help. > |
From: Franck A. <fr...@ne...> - 2008-08-06 21:46:28
|
Müller Gloria: > Something unrelated. I wanted to time my code. Is it really that Eiffel > can only measure time up to a precision of seconds? If I want to time > my code I need at least nanoseconds. "at least"? you know typical CPUs have a frequency of about 2GHz that is 1 cycle is about 0.5 nanoseconds. I don't think anyone needs to measure any kind of high level code at that level of granularity. besides I don't think you can implement that precision, just the operation of taking the measurement (in so far as there is any hardware you can buy that has the capability) and giving it back to you is going to take multiple instructions thus already way above your precision... that said, depending on the application, milliseconds might be useful. > Using command line "time" is inconvenient. and it's not going to give you nanosecond precision either. |
From: Müller G. <glm...@st...> - 2008-08-08 00:11:47
|
Hi Franck Arnaud Sorry my fault I meant in fact milliseconds. I had also already written something measuring milliseconds. Not sure why you didnt get that email tho so i attach it again. To this list: I made a second typo: I wrote something like "ISE Eiffel _compiler_ crashes" What i meant is that the Eiffel Studio crashes. Does anyone know how to use the ISE compiler on the comand line? I am using Mac. Thanks for your help Gloria |