Browse Source

add code

master
Alexandros Theodotou 2 years ago
parent
commit
ec1611aea0
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 2
      .gitignore
  2. 28410
      full_project.h
  3. 74
      main.c
  4. 16
      meson.build
  5. 3
      subprojects/libcyaml.wrap

2
.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
subprojects/libcyaml
build

28410
full_project.h

File diff suppressed because it is too large Load Diff

74
main.c

@ -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;
}

16
meson.build

@ -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)

3
subprojects/libcyaml.wrap

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
[wrap-git]
url = https://git.sr.ht/~alextee/zrythm-libcyaml
revision = fast-strings
Loading…
Cancel
Save