Confuzzled Posted May 25, 2022 Share Posted May 25, 2022 Scenario: Running a long process to delete emails programmatically in a loop by accessing the Outlook object using OutlookEX UDF invoked from SciTE-Lite Version 3.5.4 on Windows 10 machine. Console output shown below. Please note the scientific notation for the time elapsed. +>19:39:43 Starting AutoIt3Wrapper v.2.0.0.3 Environment(Language:0409 Keyboard:00000409 OS:WIN_VISTA/ CPU:X64 OS:X86) >Running AU3Check (3.3.15.0) from:C:\Program Files\AutoIt3 +>19:39:44 AU3Check ended.rc:0 >Running:(3.3.15.0):C:\Program Files\AutoIt3\autoit3.exe.... <<console output for long job - many lines, and all correctly processed>> ***Finished*** +>23:17:23 AutoIT3.exe ended.rc:0 +>23:17:24 AutoIt3Wrapper Finished >Exit code: 0 Time: 1.306e+004 A shorter job that takes about half a minutes displays the following: >Exit code: 0 Time: 31.67 1. Would appreciate elapsed time in seconds, minutes, hours, days, etc as integer or decimal, rather than scientific format. Is the variable too short to fit the values? 2. Could we also put the unit that is being displayed, eg seconds, minutes, hours, days etc that elapsed? 3. Could we have a space just prior to the rc=0, and after Language:0409, and after Keyboard:000 colons please? (see AutoIT3Wrapper first line output) Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2022 Developers Share Posted May 25, 2022 (edited) 1 hour ago, Confuzzled said: 1. Would appreciate elapsed time in seconds, minutes, hours, days, etc as integer or decimal, rather than scientific format. Is the variable too short to fit the values? 2. Could we also put the unit that is being displayed, eg seconds, minutes, hours, days etc that elapsed? 3. Could we have a space just prior to the rc=0, and after Language:0409, and after Keyboard:000 colons please? (see AutoIT3Wrapper first line output) Any mayo or ketchup with that? 1&2: This comes from SciTE and is part of the standard SciTE package. >Exit code: 0 Time: 31.67 The other suggestion is part of AutoIt3Wrapper and simple to change. Edited May 25, 2022 by Jos Musashi and TheDcoder 2 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Confuzzled Posted May 25, 2022 Author Share Posted May 25, 2022 Thanks, I'll report the first two there. The third is when you are there in the code, you may as well do it. Mayo is fattening - no coffee for you! 🙂 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2022 Developers Share Posted May 25, 2022 (edited) 59 minutes ago, Jos said: 3. Could we have a space just prior to the rc=0, and after Language:0409, and after Keyboard:000 colons please? (see AutoIT3Wrapper first line output) I have added a space before rc:0 in any standard lines like these: AU3Check ended. rc:0 AutoIT3 ended. rc:0 I won't be changing any spacing around the colons in RC:0 Language:0409 Keyboard:000 Jos Edited May 25, 2022 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Confuzzled Posted May 25, 2022 Author Share Posted May 25, 2022 Had a peek at the source code of Scintilla release 5.2.3 in the ElapsedPeriod.h module: // Scintilla source code edit control /** @file ElapsedPeriod.h ** Encapsulate C++ <chrono> to simplify use. **/ // Copyright 2018 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. #ifndef ELAPSEDPERIOD_H #define ELAPSEDPERIOD_H namespace Scintilla::Internal { // Simplified access to high precision timing. class ElapsedPeriod { using ElapsedClock = std::chrono::steady_clock; ElapsedClock::time_point tp; public: /// Capture the moment ElapsedPeriod() noexcept : tp(ElapsedClock::now()) { } /// Return duration as floating point seconds double Duration(bool reset=false) noexcept { const ElapsedClock::time_point tpNow = ElapsedClock::now(); const std::chrono::duration<double> duration = std::chrono::duration_cast<std::chrono::duration<double>>(tpNow - tp); if (reset) { tp = tpNow; } return duration.count(); } }; } #endif Double? Link to comment Share on other sites More sharing options...
Confuzzled Posted May 25, 2022 Author Share Posted May 25, 2022 (edited) catch.hpp module - lines 2053 to 2146 seem to be relevant... version 2.13.7 from Two Blue Cubes Ltd expandcollapse popup// Separate std::chrono::duration specialization #if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) #include <ctime> #include <ratio> #include <chrono> namespace Catch { template <class Ratio> struct ratio_string { static std::string symbol(); }; template <class Ratio> std::string ratio_string<Ratio>::symbol() { Catch::ReusableStringStream rss; rss << '[' << Ratio::num << '/' << Ratio::den << ']'; return rss.str(); } template <> struct ratio_string<std::atto> { static std::string symbol(); }; template <> struct ratio_string<std::femto> { static std::string symbol(); }; template <> struct ratio_string<std::pico> { static std::string symbol(); }; template <> struct ratio_string<std::nano> { static std::string symbol(); }; template <> struct ratio_string<std::micro> { static std::string symbol(); }; template <> struct ratio_string<std::milli> { static std::string symbol(); }; //////////// // std::chrono::duration specializations template<typename Value, typename Ratio> struct StringMaker<std::chrono::duration<Value, Ratio>> { static std::string convert(std::chrono::duration<Value, Ratio> const& duration) { ReusableStringStream rss; rss << duration.count() << ' ' << ratio_string<Ratio>::symbol() << 's'; return rss.str(); } }; template<typename Value> struct StringMaker<std::chrono::duration<Value, std::ratio<1>>> { static std::string convert(std::chrono::duration<Value, std::ratio<1>> const& duration) { ReusableStringStream rss; rss << duration.count() << " s"; return rss.str(); } }; template<typename Value> struct StringMaker<std::chrono::duration<Value, std::ratio<60>>> { static std::string convert(std::chrono::duration<Value, std::ratio<60>> const& duration) { ReusableStringStream rss; rss << duration.count() << " m"; return rss.str(); } }; template<typename Value> struct StringMaker<std::chrono::duration<Value, std::ratio<3600>>> { static std::string convert(std::chrono::duration<Value, std::ratio<3600>> const& duration) { ReusableStringStream rss; rss << duration.count() << " h"; return rss.str(); } }; //////////// // std::chrono::time_point specialization // Generic time_point cannot be specialized, only std::chrono::time_point<system_clock> template<typename Clock, typename Duration> struct StringMaker<std::chrono::time_point<Clock, Duration>> { static std::string convert(std::chrono::time_point<Clock, Duration> const& time_point) { return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch"; } }; // std::chrono::time_point<system_clock> specialization template<typename Duration> struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> { static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) { auto converted = std::chrono::system_clock::to_time_t(time_point); Edited May 25, 2022 by Confuzzled Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2022 Developers Share Posted May 25, 2022 (edited) Nah .... Think it should be changed in the SciTE code in SciTEWin.cxx: stExitMessage << ">Exit code: " << exitcode; if (jobQueue.TimeCommands()) { stExitMessage << " Time: "; stExitMessage << std::setprecision(4) << cmdWorker.commandTime.Duration(); } ... but I am not going to make changes in my version for this as I assume 99.99% of the usage of SciTE this isn't applicable plus it is really only "cosmetic". Maybe Neil is interested to change this in the Core version which I use when I update out version. Edited May 25, 2022 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Musashi Posted May 25, 2022 Share Posted May 25, 2022 6 hours ago, Confuzzled said: Scenario: Running a long process to delete emails programmatically in a loop ... Console output shown below. Please note the scientific notation for the time elapsed. >Exit code: 0 Time: 1.306e+004 Just out of curiosity : Wouldn't it be far easier and less invasive to use AutoIt's internal functions for time measurement ? Example : #include <Timers.au3> HotKeySet("{ESC}", _Terminate) ; just to terminate this example OnAutoItExitRegister("_MyExitFunc") Local $hStarttime = _Timer_Init() ; do something While True Sleep(50) WEnd Func _MyExitFunc() ConsoleWrite("Time elapsed = " & _Timer_Diff($hStarttime) & @CRLF) EndFunc ;==>_MyExitFunc Func _Terminate() Exit EndFunc ;==>_Terminate "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Confuzzled Posted May 26, 2022 Author Share Posted May 26, 2022 (edited) Musashi: Of course I could add this elapsed timer to my code as a wrapper, but it is the console where the aberration is happening. I like to have the problem solved once and for all rather than implement workarounds globally. Do you unwind the workarounds once the problem gets fixed? Yikes - imagine all the releases, version control activity, and associated support issues for each bit of code. I have absolute trust in Jos to make the tweaks as time permits. Knowing most programmers, they absolutely hate to do a new release with known (minor) issues! Edited May 26, 2022 by Confuzzled Musashi 1 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2022 Developers Share Posted May 26, 2022 (edited) 2 hours ago, Confuzzled said: I have absolute trust in Jos to make the tweaks as time permits. As stated: I won't be making this (rather easy) change myself in the SciTE4AutoIt3 version unless it is made in the official version published by Neil Hodgson, which I use to apply my changes specifically for AutoIt3. I doubt many people will be running scripts from SciTE that take longer than a day as to me SciTE is used to develop scripts and not to run them for a long period. Edited May 26, 2022 by Jos Musashi and seadoggie01 2 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Confuzzled Posted June 8, 2022 Author Share Posted June 8, 2022 It wasn't even four hours - just "1.306e+004" and I think it is seconds, based on the second part of my first post. The point is it should be shown, and be understandable. Scientific notation is for scientists, not coders! Link to comment Share on other sites More sharing options...
Developers Jos Posted June 8, 2022 Developers Share Posted June 8, 2022 So what did Neil say when you asked? jchd 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Confuzzled Posted June 13, 2022 Author Share Posted June 13, 2022 (edited) On 6/8/2022 at 11:36 PM, Jos said: So what did Neil say when you asked? He asked to report it to the mailing list as a feature request, or write a wrapper around it (as Musashi suggested) Sorry to have wasted everybody's time (pun intended) - I will just write shorter code in the future. Edited June 13, 2022 by Confuzzled Link to comment Share on other sites More sharing options...
Developers Jos Posted June 13, 2022 Developers Share Posted June 13, 2022 1 hour ago, Confuzzled said: He asked to report it to the mailing list as a feature request This could be a "The luxe option" with this change in SciTEWin.cxx: ::GetExitCodeProcess(pi.hProcess, &exitcode); std::ostringstream stExitMessage; stExitMessage << ">Exit code: " << exitcode; if (jobQueue.TimeCommands()) { stExitMessage << " Time: "; //+++ Start Update +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Old: stExitMessage << std::setprecision(4) << cmdWorker.commandTime.Duration(); // New code double Duration = cmdWorker.commandTime.Duration(); // Below 1 minute : 59.9 seconds // Longer than 1 min: 23:59:59.9 // Longer than 1 day: 99 days 11:22:33.4 char sDuration[20]; // convert seconds into hr, min, sec int days = (int)((int)Duration / (3600 * 24)); int hr = ((int)((int)Duration % (3600 * 24))) / 3600;; int min = ((int)((int)Duration % 3600)) / 60; double sec = Duration - (days * 3600 * 243) - (hr * 3600) - (min * 60); if (days > 0) stExitMessage << days << " days, "; if (hr > 0 || min > 0) { sprintf(sDuration, "%02d:%02d:%04.1f", hr, min, sec); } else { sprintf(sDuration, "%4.1f seconds", sec); } stExitMessage << sDuration; //=+= End Update ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } stExitMessage << "\n"; OutputAppendStringSynchronised(stExitMessage.str().c_str()); SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mLipok Posted June 13, 2022 Share Posted June 13, 2022 On 6/8/2022 at 10:21 AM, Confuzzled said: just "1.306e+004" and I think it is seconds Is it micro seconds ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Confuzzled Posted June 16, 2022 Author Share Posted June 16, 2022 I was running it on a Windows 10 machine, not a quantum computer! You have just proved my point - nobody knows the units, as they are not mentioned, and not in a understandable format. Link to comment Share on other sites More sharing options...
argumentum Posted June 16, 2022 Share Posted June 16, 2022 (edited) 57 minutes ago, Confuzzled said: nobody knows the units, as they are not mentioned .. is in seconds. But this is AutoIt and the time the editor say it was running is quite meaningless for fraction of seconds. Use a timer ( as @Musashi posted above ) if that measurement has importance. But I do agree that a scientific notation can mess with one's visual Feng Shui Edit: This is my take at a timer thing: OnAutoItExitRegister("_MyExitFunc") Global $g___hStarttime = TimerInit() Func _MyExitFunc() ConsoleWrite(@CRLF & "- Time elapsed = " & TimeTimerDiff( TimerDiff($g___hStarttime) ) & @CRLF & @CRLF) EndFunc ;==>_MyExitFunc Func TimeTimerDiff($ms) Local $day, $iHours, $iMins, $iSecs, $iTicks = $ms, $sMsOut = $ms $iTicks = Int($iTicks / 1000) $iHours = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $iMins = Int($iTicks / 60) $iSecs = Mod($iTicks, 60) If $iHours > 23 Then $day = $iHours / 24 $iHours = Mod($iHours, 24) EndIf $ms = "0000" & $ms Return $sMsOut & @TAB & StringReplace(StringFormat("%03i %02i:%02i:%02i", $day, $iHours, $iMins, $iSecs), "000 ", "") & '.' & StringReplace(StringTrimLeft($ms, StringInStr($ms, ".") - 4), ".", ",") EndFunc ;==>TimeTimerDiff ;~ Sleep(1) Exit I find this clear and readable. Edited June 16, 2022 by argumentum nicer looking Musashi 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Confuzzled Posted June 16, 2022 Author Share Posted June 16, 2022 I'm going to sincerely thank you for your effort to post added 22 lines of code to bypass an easily fixable issue. The entire AutoIT cohort is welcome to add the code as a wrapper to 'fix' the issue. See any issues with that statement? Looks like Neil and Jos are already on the correct solution. I await the new version with the simple fix rolled out. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 16, 2022 Developers Share Posted June 16, 2022 1 hour ago, Confuzzled said: Looks like Neil and Jos are already on the correct solution. Do you have a link for the request you made? I don't see it in the SciTE-Interest maillist or Sourceforge.net. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now