trace.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. Without limiting anything contained in the foregoing, this file,
  12. which is part of C Driver for MySQL (Connector/C), is also subject to the
  13. Universal FOSS Exception, version 1.0, a copy of which can be found at
  14. http://oss.oracle.com/licenses/universal-foss-exception.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License, version 2.0, for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  22. #include <algorithm>
  23. #include <chrono>
  24. #include <fstream>
  25. #include <iostream>
  26. #include <list>
  27. #include <mutex>
  28. #include <string>
  29. #include <thread>
  30. #include "my_dbug.h"
  31. using std::chrono::duration_cast;
  32. using std::chrono::high_resolution_clock;
  33. using std::chrono::nanoseconds;
  34. using std::chrono::time_point;
  35. static std::list<std::string> g_debug_lst;
  36. void fn_print_string(const std::string &m) { std::cout << m << std::endl; }
  37. void dump_trace() {
  38. for_each(g_debug_lst.begin(), g_debug_lst.end(), fn_print_string);
  39. }