"Fossies" - the Fresh Open Source Software Archive

Member "dlib-19.18/docs/dlib/time_this.h.html" (22 Sep 2019, 8127 Bytes) of package /linux/misc/dlib-19.18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - time_this.h</title></head><body bgcolor='white'><pre>
    2 <font color='#009900'>// Copyright (C) 2003  Davis E. King (davis@dlib.net)
    3 </font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
    4 </font><font color='#0000FF'>#ifndef</font> DLIB_TIME_THIs_
    5 <font color='#0000FF'>#define</font> DLIB_TIME_THIs_
    6 
    7 
    8 <font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>chrono<font color='#5555FF'>&gt;</font>
    9 
   10 <font color='#009900'>// ----------------------------------------------------------------------------------------
   11 </font>
   12 <font color='#0000FF'>#define</font> TIME_THIS_TO<font face='Lucida Console'>(</font>_tt_op,_tt_out<font face='Lucida Console'>)</font>                                                                            \
   13     <b>{</b>                                                                                                           \
   14         <font color='#0000FF'>auto</font> _tt_start <font color='#5555FF'>=</font> std::chrono::high_resolution_clock::<font color='#BB00BB'>now</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;                                             \
   15         <b>{</b>_tt_op;<b>}</b>                                                                                               \
   16         <font color='#0000FF'>auto</font> _tt_stop <font color='#5555FF'>=</font> std::chrono::high_resolution_clock::<font color='#BB00BB'>now</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;                                              \
   17         <font color='#0000FF'>auto</font> _tt_thetime <font color='#5555FF'>=</font> _tt_stop<font color='#5555FF'>-</font>_tt_start;                                                                          \
   18         <font color='#0000FF'>using</font> std::chrono::duration_cast;                                                                       \
   19         <font color='#0000FF'>using</font> std::chrono::duration;                                                                            \
   20         <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>_tt_thetime <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> std::chrono::<font color='#BB00BB'>minutes</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>                                                             \
   21             _tt_out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\ntime: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> duration_cast<font color='#5555FF'>&lt;</font>duration<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,std::ratio<font color='#5555FF'>&lt;</font><font color='#979000'>60</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>_tt_thetime<font face='Lucida Console'>)</font>.<font color='#BB00BB'>count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>min\n</font>";           \
   22         <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>_tt_thetime <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> std::chrono::<font color='#BB00BB'>seconds</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>                                                        \
   23             _tt_out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\ntime: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> duration_cast<font color='#5555FF'>&lt;</font>duration<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>_tt_thetime<font face='Lucida Console'>)</font>.<font color='#BB00BB'>count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>sec\n</font>";           \
   24         <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>_tt_thetime <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> std::chrono::<font color='#BB00BB'>milliseconds</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>                                                   \
   25             _tt_out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\ntime: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> duration_cast<font color='#5555FF'>&lt;</font>duration<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,std::milli<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>_tt_thetime<font face='Lucida Console'>)</font>.<font color='#BB00BB'>count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>ms\n</font>"; \
   26         <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>_tt_thetime <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> std::chrono::<font color='#BB00BB'>microseconds</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>                                                   \
   27             _tt_out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\ntime: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> duration_cast<font color='#5555FF'>&lt;</font>duration<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,std::micro<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>_tt_thetime<font face='Lucida Console'>)</font>.<font color='#BB00BB'>count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>us\n</font>"; \
   28         <font color='#0000FF'>else</font>                                                                                                    \
   29             _tt_out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\ntime: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> duration_cast<font color='#5555FF'>&lt;</font>duration<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,std::nano<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>_tt_thetime<font face='Lucida Console'>)</font>.<font color='#BB00BB'>count</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>ns\n</font>";  \
   30     <b>}</b>
   31 
   32 <font color='#0000FF'>#define</font> TIME_THIS<font face='Lucida Console'>(</font>_tt_op<font face='Lucida Console'>)</font>  TIME_THIS_TO<font face='Lucida Console'>(</font>_tt_op,std::cout<font face='Lucida Console'>)</font>
   33 
   34 <font color='#009900'>// ----------------------------------------------------------------------------------------
   35 </font>
   36 <font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_TIME_THIs_
   37 </font>
   38 
   39 </pre></body></html>