1 /* 2 * CUPS cupsGetDests API test program for CUPS. 3 * 4 * Copyright 2017 by Apple Inc. 5 * 6 * Licensed under Apache License v2.0. See the file "LICENSE" for more information. 7 */ 8 9 /* 10 * Include necessary headers... 11 */ 12 13 #include <stdio.h> 14 #include "cups.h" 15 #include <sys/time.h> 16 17 18 /* 19 * 'main()' - Loop calling cupsGetDests. 20 */ 21 22 int /* O - Exit status */ main(void)23main(void) 24 { 25 int num_dests; /* Number of destinations */ 26 cups_dest_t *dests; /* Destinations */ 27 struct timeval start, end; /* Start and stop time */ 28 double secs; /* Total seconds to run cupsGetDests */ 29 30 31 for (;;) 32 { 33 gettimeofday(&start, NULL); 34 num_dests = cupsGetDests(&dests); 35 gettimeofday(&end, NULL); 36 secs = end.tv_sec - start.tv_sec + 0.000001 * (end.tv_usec - start.tv_usec); 37 38 printf("Found %d printers in %.3f seconds...\n", num_dests, secs); 39 40 cupsFreeDests(num_dests, dests); 41 sleep(1); 42 } 43 44 return (0); 45 } 46