Droplet Lagrangian Transient One-dimensional Reacting Code Implementation of both liquid and gas phase governing equations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0KB

  1. // Windows
  2. #ifdef _WIN32
  3. #include <Windows.h>
  4. double get_wall_time(){
  5. LARGE_INTEGER time,freq;
  6. if (!QueryPerformanceFrequency(&freq)){
  7. // Handle error
  8. return 0;
  9. }
  10. if (!QueryPerformanceCounter(&time)){
  11. // Handle error
  12. return 0;
  13. }
  14. return (double)time.QuadPart / freq.QuadPart;
  15. }
  16. double get_cpu_time(){
  17. FILETIME a,b,c,d;
  18. if (GetProcessTimes(GetCurrentProcess(),&a,&b,&c,&d) != 0){
  19. // Returns total user time.
  20. // Can be tweaked to include kernel times as well.
  21. return
  22. (double)(d.dwLowDateTime |
  23. ((unsigned long long)d.dwHighDateTime << 32)) * 0.0000001;
  24. }else{
  25. // Handle error
  26. return 0;
  27. }
  28. }
  29. // Posix/Linux
  30. #else
  31. #include <time.h>
  32. #include <sys/time.h>
  33. double get_wall_time(){
  34. struct timeval time;
  35. if (gettimeofday(&time,NULL)){
  36. // Handle error
  37. return 0;
  38. }
  39. return (double)time.tv_sec + (double)time.tv_usec * .000001;
  40. }
  41. double get_cpu_time(){
  42. return (double)clock() / CLOCKS_PER_SEC;
  43. }
  44. #endif