EpikTimer/fr: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | 1 | ### A propos | |
| 18 | 2 | ||
| 19 | - | ||
| 3 | + | EpikTimer un chronomètre pour le programmeur qui est capable de mesurer des événements très court avec une précision traçable sur de longues périodes de temps. Il est simple à utiliser, consomme pratiquement pas de temps processeur et ne nécessite que 25 octets de RAM pour mettre en œuvre une instance de l'horloge. Le composant fournit un seul temporisateur interne... mais un nombre illimité peut être déclarée extérieurement et lié à un seul composant EpikTimer sur le formulaire(form). | |
| 20 | 4 | ||
| 21 | - | ||
| 5 | + | Le téléchargement contient le composant, un paquet d'installation et une application de démonstration, qui illustre les caractéristiques du composante ainsi que certains outils pour évaluer les sources d'horloge sur un système donné. | |
| 22 | 6 | ||
| 23 | - | ||
| 7 | + | Ce composant a été conçu pour des applications multi-plateformes et a été écrit spécifiquement pour l'IDE Lazarus et le compilateur Free Pascal et comprend une application de démonstration. | |
| 24 | 8 | ||
| 25 | 9 | ### Auteur | |
| 26 | 10 | ||
| 27 | - | ||
| 11 | + | Tom Lisjac | |
| 28 | 12 | ||
| 29 | 13 | #### Contributeurs | |
| 30 | 14 | ||
| 31 | - | ||
| 32 | - | ||
| 15 | + | - Felipe Monteiro de Carvalho | |
| 16 | + | - Marcel Minderhoud | |
| 33 | 17 | ||
| 34 | 18 | ### Licence | |
| 35 | 19 | ||
| 36 | - | ||
| 20 | + | [LGPL](http://www.opensource.org/licenses/lgpl-license.php) (veuillez contacter l'auteur si la licence LGPL ne correspond pas avec la licence de votre projet) | |
| 37 | 21 | ||
| 38 | 22 | ### Subversion | |
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | 23 | ||
| 24 | + | svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/epiktimer epiktimer | |
| 25 | + | ||
| 43 | 26 | ### Téléchargement | |
| 44 | 27 | ||
| 45 | - | ||
| 28 | + | La dernière version stable peut être trouvée sur la [page des fichiers Lazarus CCR](http://sourceforge.net/project/showfiles.php?group_id=92177) ou [ici](http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=98235). | |
| 46 | 29 | ||
| 47 | - | ||
| 30 | + | Statut: Production/Stable | |
| 48 | 31 | ||
| 49 | 32 | ### Change Log | |
| 50 | 33 | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - | ||
| 34 | + | - Initially written on 24-06-2003 TL | |
| 35 | + | - Pre-release 30-06-2003 TL - Needs testing on the BSD's and Win32 | |
| 36 | + | - Version 0.1 1-7-2003 TL | |
| 54 | 37 | ||
| 55 | - | ||
| 38 | + | 1. initial beta release | |
| 56 | 39 | ||
| 57 | - | ||
| 40 | + | - Version 0.2 3-7-2003 TL | |
| 58 | 41 | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 42 | + | 1. Revised logic around hardware detection to prevent executing extended instructions if the HasCapabilityData call returns false. | |
| 43 | + | 2. Removed exposed low level diagnositic functions from unit interface. | |
| 44 | + | 3. Revised demo. | |
| 62 | 45 | ||
| 63 | - | ||
| 46 | + | - Version 0.3 15-11-2005 | |
| 64 | 47 | ||
| 65 | - | ||
| 66 | - | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | - | ||
| 71 | - | ||
| 48 | + | 1. Updated 0.2 version to make it compile on the latest Lazarus (0.9.10). | |
| 49 | + | 2. Added LCL to the required packages. | |
| 50 | + | 3. Changed mode to Delphi in order to compile. | |
| 51 | + | 4. Changed windows timebase to use QueryPerformanceCounter, because has a much greater precision then GetSystemTime. | |
| 52 | + | 5. Added changes to ensure the component compiles on Delphi 7.0 | |
| 53 | + | 6. Made tests on Windows and Linux | |
| 54 | + | 7. Small changes to the demo to make it compile | |
| 72 | 55 | ||
| 73 | - | ||
| 56 | + | - Version 1.0 06-10-2006 | |
| 74 | 57 | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 58 | + | 1. Changes for 64 bits operation | |
| 59 | + | 2. Added units BaseUnix, Unix and UnixUtil, removed oldlinux (obsolete) | |
| 60 | + | 3. Gettimeofday -\> fpGettimeofday | |
| 61 | + | 4. Changed systemsleep for 64 bits systems | |
| 62 | + | 5. Some changes in timeval | |
| 63 | + | 6. Tested on AMD64 (linux) | |
| 81 | 64 | ||
| 82 | 65 | ### Dépendances / Configuration requise | |
| 83 | 66 | ||
| 84 | - | ||
| 85 | - | ||
| 67 | + | - la résolution nanoseconde est prise en charge sur les versions Intel Pentium avec un compteur d'évènements dans le temps. | |
| 68 | + | - l'horloge système microseconde est la base de temps par défaut. | |
| 86 | 69 | ||
| 87 | - | ||
| 70 | + | Testé sur: | |
| 88 | 71 | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - | ||
| 72 | + | - Pentium IV 3,2Mhz sur Windows et Linux avec une grande précision (~ 3,220,000,000 impulsions par seconde) | |
| 73 | + | - Pentium 233Mhz avec Damn Small Linux. Fonctionne merveilleusement avec l'horloge matérielle. | |
| 74 | + | - Mobile AMD 64 Athlon 3200+ sur Windows XP Home (32 bit), Lazarus 9.13 | |
| 75 | + | - AMD 64 CPU, exécution de la version 64 bit d'Ubuntu Linux, Lazarus 9.18. | |
| 93 | 76 | ||
| 94 | - | ||
| 77 | + | Issues: Besoins de test sur FreeBSD et de plus vieilles machines qui manquent de matériel TSC. | |
| 95 | 78 | ||
| 96 | 79 | ### Installation | |
| 97 | 80 | ||
| 98 | - | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - | ||
| 81 | + | - In Components/Open Package File, open etpackage.lpk. | |
| 82 | + | - Compile the component to verify that everything is there. | |
| 83 | + | - Install and let Lazarus rebuild | |
| 84 | + | - Component will be in the System Palette (stopwatch-ruler icon) | |
| 102 | 85 | ||
| 103 | 86 | ### Usage | |
| 104 | 87 | ||
| 105 | - | ||
| 88 | + | Drop the component on a form. The component contains a single timer instance and parameterless calls to start, stop, elapsed and clear will implicitly reference it. | |
| 106 | 89 | ||
| 107 | 90 | **If the timer is named ET** | |
| 108 | - | ||
| 91 | + | ||
| 92 | + | ``` pascal | |
| 109 | 93 | uses epiktimer; | |
| 110 | - | ||
| 111 | - | ||
| 112 | - | ||
| 113 | - | ||
| 114 | - | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - | ||
| 118 | - | ||
| 119 | - | ||
| 120 | - | ||
| 121 | - | ||
| 122 | - | ||
| 123 | - | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - | ||
| 128 | - | ||
| 129 | - | ||
| 130 | - | ||
| 131 | - | ||
| 132 | - | ||
| 133 | - | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - | ||
| 137 | - | ||
| 138 | 94 | ||
| 139 | - | ||
| 95 | + | var | |
| 96 | + | ET: TEpikTimer; | |
| 97 | + | ||
| 98 | + | procedure InitTimer; | |
| 99 | + | begin | |
| 100 | + | ET := TEpikTimer.Create(Application); | |
| 101 | + | end; | |
| 102 | + | ||
| 103 | + | procedure InstrumentedCall; | |
| 104 | + | Begin | |
| 105 | + | ET.Clear; // optional... timer is cleared at creation | |
| 106 | + | ET.Start; | |
| 107 | + | ExecuteFirstTimedSection; | |
| 108 | + | ET.Stop; // the timer is actually paused and can be restarted later | |
| 109 | + | TimedSection1:=ET.Elapsed; // store the elapsed in a global | |
| 110 | + | MakeAnUntimedOverheadCall; // not counted in the timer | |
| 111 | + | ET.Start; //resume the timer... continue accumulating ticks | |
| 112 | + | CallTimedSection2; | |
| 113 | + | TimedSection2:=ET.Elapsed; //timer keeps running... we've just sample it. | |
| 114 | + | CallTimedSection3; | |
| 115 | + | CallSomethingElse; | |
| 116 | + | TimedSection3:=ET.Elapsed; //keep counting... tap the elapsed | |
| 117 | + | CallTimedSection4; | |
| 118 | + | TimedSection4:=ET.Elapsed; //keep counting... tap the elapsed | |
| 119 | + | ET.clear // done... timer is stopped and zeroed | |
| 120 | + | end; | |
| 140 | 121 | ``` | |
| 122 | + | ||
| 123 | + | You can also create any number of timers from a single component on the form by declaring a TimerData record and passing it as a parameter to start, stop, elapsed and clear using the overloaded methods in the component. An example would be: | |
| 124 | + | ||
| 125 | + | ``` pascal | |
| 141 | 126 | Function TimedExecution: Extended; | |
| 142 | - | ||
| 143 | - | ||
| 144 | - | ||
| 145 | - | ||
| 146 | - | ||
| 147 | - | ||
| 148 | - | ||
| 149 | - | ||
| 127 | + | Var | |
| 128 | + | DiskAccessTime:TimerData; | |
| 129 | + | Begin | |
| 130 | + | ET.Clear(DiskAccessTimer); // Declared timers *must* be cleared before use. | |
| 131 | + | ET.Start(DiskAccessTimer); | |
| 132 | + | ExecuteTheTimedSection; | |
| 133 | + | Result:=ET.Elapsed(DiskAccessTimer); // the timer keeps running... | |
| 134 | + | etc... | |
| 150 | 135 | ``` | |
| 151 | 136 | ||
| 152 | - | ||
| 153 | - | ||
| 137 | + | One particular use for EpikTimer is checking if a given amount of time has elapsed before continuing with a task or to another iteration of the same task. | |
| 138 | + | ||
| 139 | + | ``` pascal | |
| 154 | 140 | DelayInSeconds := 8.5; // or any value | |
| 155 | - | ||
| 156 | - | ||
| 157 | - | ||
| 158 | - | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 141 | + | OldTime := ET.Elapse; | |
| 142 | + | ||
| 143 | + | while ((ET.Elapsed - OldTime) < DelayInSeconds) do | |
| 144 | + | begin | |
| 145 | + | ET.SystemSleep(10); | |
| 146 | + | end; | |
| 147 | + | ||
| 148 | + | // DelayInSeconds has elapsed and now you can continue executing the code | |
| 163 | 149 | ``` | |
| 164 | 150 | ||
| 165 | - | ||
| 151 | + | See etdemo.pas for additional examples of component usage | |
| 166 | 152 | ||
| 167 | 153 | #### EpikTimer as a profiler | |
| 168 | 154 | ||
| 169 | - | ||
| 170 | - | ||
| 155 | + | EpikTimer can be used to profile the speed of procedures: | |
| 156 | + | ||
| 157 | + | ``` pascal | |
| 171 | 158 | uses | |
| 172 | - | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - | ||
| 176 | - | ||
| 177 | - | ||
| 178 | - | ||
| 179 | - | ||
| 180 | - | ||
| 181 | - | ||
| 182 | - | ||
| 183 | - | ||
| 184 | - | ||
| 185 | - | ||
| 186 | - | ||
| 187 | - | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | - | ||
| 192 | - | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - | ||
| 197 | - | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - | ||
| 205 | - | ||
| 206 | - | ||
| 207 | - | ||
| 159 | + | {$ifdef PROFILING}epiktimer,{$endif} | |
| 160 | + | ... | |
| 161 | + | ||
| 162 | + | type | |
| 163 | + | TMyClass = class | |
| 164 | + | private | |
| 165 | + | {$ifdef PROFILING} | |
| 166 | + | profiler: Tepiktimer; | |
| 167 | + | {$endif} | |
| 168 | + | ... | |
| 169 | + | end; | |
| 170 | + | ||
| 171 | + | implementation | |
| 172 | + | ||
| 173 | + | constructor TMyClass.Create(AOwner: TComponent); | |
| 174 | + | begin | |
| 175 | + | inherited Create(AOwner); | |
| 176 | + | ||
| 177 | + | ... | |
| 178 | + | ||
| 179 | + | {$ifdef CARDROOM_PROFILING} | |
| 180 | + | profiler := TEpikTimer.Create(Self) | |
| 181 | + | {$endif} | |
| 182 | + | end; | |
| 183 | + | ||
| 184 | + | procedure TMyClass.MethodToBeProfiled; | |
| 185 | + | begin | |
| 186 | + | {$ifdef PROFILING} | |
| 187 | + | profiler.Clear; | |
| 188 | + | profiler.Start; | |
| 189 | + | {$endif} | |
| 190 | + | // do stuff | |
| 191 | + | {$ifdef PROFILING} | |
| 192 | + | OPDebugLn('TMyClass.MethodToBeProfiled ' + FloatToStr(profiler.Elapsed)); | |
| 193 | + | {$endif} | |
| 194 | + | end; | |
| 208 | 195 | ``` | |
| 209 | 196 | ||
| 210 | 197 | ### The ETDemo Application | |
| 211 | 198 | ||
| 212 | - | ||
| 199 | + | The ETDemo application does not require EpikTimer to be installed in order to compile and operate. I never liked having to install a palette full of components only to find out that I didn't like any of them! :) | |
| 213 | 200 | ||
| 214 | 201 | **Installation** | |
| 215 | 202 | ||
| 216 | - | ||
| 217 | - | ||
| 218 | - | ||
| 203 | + | - Open etdemo.lpi | |
| 204 | + | - compile | |
| 205 | + | - run | |
| 219 | 206 | ||
| 220 | 207 | ### Original contributors | |
| 221 | 208 | ||
| 222 | - | ||
| 209 | + | This page has been converted from epikwiki. Original content by Tom Lisjac. | |
| 223 | 210 | ||
| 224 | 211 | --- | |
| 225 | - | ||
| 212 | + | *From the Free Pascal wiki, page "EpikTimer/fr", as it stood on 2020-02-14 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 213 | + | Category: Components/fr |
