Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 12 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <wiringPi.h>
  4. #include <time.h>
  5. #include <sys/types.h>
  6. #include <sys/time.h>
  7. #define CYCLES 1000
  8. #define DELAY 99
  9. int main()
  10. {
  11. int x ;
  12. struct timeval t1, t2 ;
  13. long long t ;
  14. unsigned int max, min ;
  15. unsigned int values [CYCLES] ;
  16. max = 0 ;
  17. min = 1000000 ;
  18. if (wiringPiSetup () == -1)
  19. return 1 ;
  20. piHiPri (10) ;
  21. sleep (1) ;
  22. // Baseline test
  23. gettimeofday (&t1, NULL) ;
  24. gettimeofday (&t2, NULL) ;
  25. t = t2.tv_usec - t1.tv_usec ;
  26. printf ("Baseline test: %lld\n", t);
  27. for (x = 0 ; x < CYCLES ; ++x)
  28. {
  29. gettimeofday (&t1, NULL) ;
  30. delayMicroseconds (DELAY) ;
  31. gettimeofday (&t2, NULL) ;
  32. t = t2.tv_usec - t1.tv_usec ;
  33. if (t > max) max = t ;
  34. if (t < min) min = t ;
  35. values [x] = t ;
  36. }
  37. printf ("Done: Max: %d, min: %d\n", max, min) ;
  38. for (x = 0 ; x < CYCLES ; ++x)
  39. {
  40. printf ("%4d", values [x]) ;
  41. if (values [x] > DELAY)
  42. printf (".") ;
  43. else if (values [x] < DELAY)
  44. printf ("-") ;
  45. else
  46. printf (" ") ;
  47. if (((x + 1) % 20) == 0)
  48. printf ("\n") ;
  49. }
  50. printf ("\n") ;
  51. return 0 ;
  52. }