summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pchrono.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2016-06-23 02:04:40 +0200
committer couriersud <couriersud@arcor.de>2016-06-23 02:04:51 +0200
commitc6e6911aed7687b94fba52485d89f0903e102d0e (patch)
treedac88b6a6e1db607726e90bb7d7d2f5e0913ede1 /src/lib/netlist/plib/pchrono.cpp
parent224dbf1cc9fa8a6c49ee9529d3045474194667ef (diff)
Netlist changes
- Replaced shared_ptr by unique_ptr. - Better seperation of setup_t and netlist_t. - Fixed bugs in rdtsc code. Refactored timer code. - Simplify conditional activation/deactivation. - Introduced HINT(device, hint) to clarify that hints are inheritent and not specific to devices. - Added improved profiling support to netlist. Statistics output now proposes devices for which whole device activation/deactivation be disabled. No significant improvement for pong, but breakout experiences a 10% improvement. - Moved options code from include to cpp file. - Minor modifications to 7493 and 9316 - Introduced perftime_t and perfcount_t for gathering statistics. These templates do not create any code if statistics are not kept. - Make help2man ./nltool produce usuable output. - More truthtable refactoring. Removed half-finished code for internal state support. As implemented, this would have had no support for timing delays. [Couriersud]
Diffstat (limited to 'src/lib/netlist/plib/pchrono.cpp')
-rw-r--r--src/lib/netlist/plib/pchrono.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/pchrono.cpp b/src/lib/netlist/plib/pchrono.cpp
new file mode 100644
index 00000000000..3beb3b2f161
--- /dev/null
+++ b/src/lib/netlist/plib/pchrono.cpp
@@ -0,0 +1,55 @@
+// license:GPL-2.0+
+// copyright-holders:Couriersud
+
+#include <chrono>
+
+#include "pchrono.h"
+
+namespace plib {
+namespace chrono {
+
+
+#if defined(__x86_64__) && !defined(_clang__) && !defined(_MSC_VER) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6))
+
+fast_ticks::type fast_ticks::per_second()
+{
+ static type persec = 0;
+ if (persec == 0)
+ {
+ type x = 0;
+ system_ticks::type t = system_ticks::start();
+ system_ticks::type e;
+ x = -start();
+ do {
+ e = system_ticks::stop();
+ } while (e - t < system_ticks::per_second() / 100 );
+ x += stop();
+ persec = (type)(double)((double) x * (double) system_ticks::per_second() / double (e - t));
+ }
+ return persec;
+}
+
+#if PUSE_ACCURATE_STATS && PHAS_RDTSCP
+exact_ticks::type exact_ticks::per_second()
+{
+ static type persec = 0;
+ if (persec == 0)
+ {
+ type x = 0;
+ system_ticks::type t = system_ticks::start();
+ system_ticks::type e;
+ x = -start();
+ do {
+ e = system_ticks::stop();
+ } while (e - t < system_ticks::per_second() / 100 );
+ x += stop();
+ persec = (type)(double)((double) x * (double) system_ticks::per_second() / double (e - t));
+ }
+ return persec;
+}
+#endif
+
+#endif
+
+}
+}