Tune deflate
parent
007578052c
commit
6dec7287f7
|
@ -69,7 +69,11 @@ int run_benchmark(const char *image)
|
||||||
|
|
||||||
z_stream zs = { 0 };
|
z_stream zs = { 0 };
|
||||||
|
|
||||||
deflateInit(&zs, Z_DEFAULT_COMPRESSION);
|
deflateInit2(&zs, /* compression level: */ 1,
|
||||||
|
/* method: */ Z_DEFLATED,
|
||||||
|
/* window bits: */ 15,
|
||||||
|
/* mem level: */ 9,
|
||||||
|
/* strategy: */ Z_DEFAULT_STRATEGY);
|
||||||
|
|
||||||
void *dummy = malloc(width * height * 4);
|
void *dummy = malloc(width * height * 4);
|
||||||
if (!dummy)
|
if (!dummy)
|
||||||
|
@ -92,6 +96,12 @@ int run_benchmark(const char *image)
|
||||||
printf("Encoding %s took %"PRIu64" micro seconds\n", image,
|
printf("Encoding %s took %"PRIu64" micro seconds\n", image,
|
||||||
end_time - start_time);
|
end_time - start_time);
|
||||||
|
|
||||||
|
double orig_size = width * height * 4;
|
||||||
|
double compressed_size = frame.len;
|
||||||
|
|
||||||
|
double reduction = (orig_size - compressed_size) / orig_size;
|
||||||
|
printf("Size reduction: %.1f %%\n", reduction * 100.0);
|
||||||
|
|
||||||
deflateEnd(&zs);
|
deflateEnd(&zs);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
|
|
@ -748,7 +748,14 @@ static void on_connection(uv_stream_t *server_stream, int status)
|
||||||
client->ref = 1;
|
client->ref = 1;
|
||||||
client->server = server;
|
client->server = server;
|
||||||
|
|
||||||
if (deflateInit(&client->z_stream, Z_BEST_SPEED) != Z_OK) {
|
int rc = deflateInit2(&client->z_stream,
|
||||||
|
/* compression level: */ 1,
|
||||||
|
/* method: */ Z_DEFLATED,
|
||||||
|
/* window bits: */ 15,
|
||||||
|
/* mem level: */ 9,
|
||||||
|
/* strategy: */ Z_DEFAULT_STRATEGY);
|
||||||
|
|
||||||
|
if (rc != Z_OK) {
|
||||||
free(client);
|
free(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue