5 changed files with 28505 additions and 0 deletions
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
#include <stdarg.h> |
||||
#include <stdlib.h> |
||||
#include <stdint.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <time.h> |
||||
|
||||
#include <cyaml/cyaml.h> |
||||
|
||||
#include "full_project.h" |
||||
|
||||
static const cyaml_config_t config = { |
||||
.log_level = CYAML_LOG_WARNING, |
||||
.log_fn = cyaml_log, |
||||
.mem_fn = cyaml_mem, |
||||
}; |
||||
|
||||
static void |
||||
serialize ( |
||||
void * project_ptr) |
||||
{ |
||||
char * output; |
||||
size_t output_len; |
||||
clock_t before = clock(); |
||||
cyaml_err_t err = |
||||
cyaml_save_data ( |
||||
&output, &output_len, |
||||
&config, &project_schema, project_ptr, 0); |
||||
if (err != CYAML_OK) |
||||
{ |
||||
fprintf (stderr, "Failed to serialize: %s\n", cyaml_strerror (err)); |
||||
exit (EXIT_FAILURE); |
||||
} |
||||
clock_t difference = clock() - before; |
||||
int msec = difference * 1000 / CLOCKS_PER_SEC; |
||||
fprintf (stderr, "Time to serialize: %dms\n", msec); |
||||
} |
||||
|
||||
static void * |
||||
deserialize ( |
||||
const char * filepath) |
||||
{ |
||||
void * obj; |
||||
clock_t before = clock(); |
||||
cyaml_err_t err = |
||||
cyaml_load_file ( |
||||
filepath, |
||||
&config, &project_schema, (cyaml_data_t **) &obj, |
||||
NULL); |
||||
if (err != CYAML_OK) |
||||
{ |
||||
fprintf (stderr, "Failed to deserialize: %s\n", cyaml_strerror (err)); |
||||
exit (EXIT_FAILURE); |
||||
} |
||||
clock_t difference = clock() - before; |
||||
int msec = difference * 1000 / CLOCKS_PER_SEC; |
||||
fprintf (stderr, "Time to deserialize: %dms\n", msec); |
||||
return obj; |
||||
} |
||||
|
||||
int main ( |
||||
int argc, |
||||
char ** argv) |
||||
{ |
||||
if (argc != 2) |
||||
{ |
||||
fprintf (stderr, "%s", "Need 1 argument\n"); |
||||
exit (EXIT_FAILURE); |
||||
} |
||||
void * obj = deserialize (argv[1]); |
||||
serialize (obj); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
project('large-yaml-test', 'c', |
||||
version : '0.1', |
||||
default_options: [ |
||||
'warning_level=3', |
||||
'buildtype=debugoptimized', |
||||
'c_std=gnu11', |
||||
]) |
||||
|
||||
cyaml_dep = dependency( |
||||
'libcyaml', version: '>=1.2.0', |
||||
fallback: ['libcyaml', 'zrythm_cyaml_dep']) |
||||
|
||||
executable('large-yaml-test', |
||||
'main.c', |
||||
dependencies: [cyaml_dep], |
||||
install : true) |
Loading…
Reference in new issue