MCPcopy Create free account
hub / github.com/OpenPrinting/cups / write_test

Function write_test

cups/rasterbench.c:249–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247 */
248
249static void
250write_test(int fd, /* I - File descriptor to write to */
251 cups_mode_t mode) /* I - Write mode */
252{
253 unsigned page, x, y; /* Looping vars */
254 unsigned count; /* Number of bytes to set */
255 cups_raster_t *r; /* Raster stream */
256 cups_page_header2_t header; /* Page header */
257 unsigned char data[32][8 * TEST_WIDTH];
258 /* Raster data to write */
259
260
261 /*
262 * Create a combination of random data and repeated data to simulate
263 * text with some whitespace.
264 */
265
266 CUPS_SRAND(time(NULL));
267
268 memset(data, 0, sizeof(data));
269
270 for (y = 0; y < 28; y ++)
271 {
272 for (x = CUPS_RAND() & 127, count = (CUPS_RAND() & 15) + 1;
273 x < sizeof(data[0]);
274 x ++, count --)
275 {
276 if (count <= 0)
277 {
278 x += (CUPS_RAND() & 15) + 1;
279 count = (CUPS_RAND() & 15) + 1;
280
281 if (x >= sizeof(data[0]))
282 break;
283 }
284
285 data[y][x] = (unsigned char)CUPS_RAND();
286 }
287 }
288
289 /*
290 * Test write speed...
291 */
292
293 if ((r = cupsRasterOpen(fd, mode)) == NULL)
294 {
295 perror("Unable to create raster output stream");
296 return;
297 }
298
299 for (page = 0; page < TEST_PAGES; page ++)
300 {
301 memset(&header, 0, sizeof(header));
302 header.cupsWidth = TEST_WIDTH;
303 header.cupsHeight = TEST_HEIGHT;
304 header.cupsBytesPerLine = TEST_WIDTH;
305
306 if (page & 1)

Callers 1

mainFunction · 0.85

Calls 4

cupsRasterOpenFunction · 0.85
cupsRasterWriteHeader2Function · 0.85
cupsRasterWritePixelsFunction · 0.85
cupsRasterCloseFunction · 0.85

Tested by

no test coverage detected