ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since d1ecd39 was
ee23a8d,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
Added duration information (in nanoseconds) to EHM benchmarks.
|
-
Property mode set to
100644
|
File size:
727 bytes
|
Rev | Line | |
---|
[ea593a3] | 1 | // Cross a Try Statement with a Termination Handler |
---|
[ee23a8d] | 2 | #include <chrono> |
---|
[ea593a3] | 3 | #include <cstdlib> |
---|
[ee23a8d] | 4 | #include <exception> |
---|
| 5 | #include <iostream> |
---|
| 6 | |
---|
| 7 | using namespace std::chrono; |
---|
[ea593a3] | 8 | |
---|
| 9 | struct NotRaisedException : public std::exception {}; |
---|
| 10 | |
---|
| 11 | int main(int argc, char * argv[]) { |
---|
| 12 | unsigned int times = 1; |
---|
[ee23a8d] | 13 | if (1 < argc) { |
---|
[ea593a3] | 14 | times = strtol(argv[1], nullptr, 10); |
---|
| 15 | } |
---|
| 16 | |
---|
[ee23a8d] | 17 | time_point<steady_clock> start_time = steady_clock::now(); |
---|
[ea593a3] | 18 | for (unsigned int count = 0 ; count < times ; ++count) { |
---|
| 19 | try { |
---|
| 20 | // ... |
---|
| 21 | } catch (NotRaisedException &) { |
---|
| 22 | // ... |
---|
| 23 | } |
---|
| 24 | } |
---|
[ee23a8d] | 25 | time_point<steady_clock> end_time = steady_clock::now(); |
---|
| 26 | nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); |
---|
| 27 | std::cout << "Run-Time (ns): " << duration.count() << std::endl; |
---|
[ea593a3] | 28 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.