mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
qemuxml2argvtest: Cache QAPI schema between tests
It's quite wasteful to reparse the QAPI schema for each _CAPS_ test. Add a simple cache filled lazily by encountered schemas. The time saving on my box is quite significant: real 0m3.318s user 0m3.203s sys 0m0.107s vs real 0m2.223s user 0m2.134s sys 0m0.084s Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
8298a5bd69
commit
9995a1af45
@ -523,13 +523,22 @@ testCompareXMLToArgvValidateSchema(virQEMUDriverPtr drv,
|
|||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
size_t nargs = 0;
|
size_t nargs = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
g_autoptr(GHashTable) schema = NULL;
|
GHashTable *schema = NULL;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
unsigned int parseFlags = info->parseFlags;
|
unsigned int parseFlags = info->parseFlags;
|
||||||
bool netdevQAPIfied = false;
|
bool netdevQAPIfied = false;
|
||||||
|
|
||||||
if (info->schemafile)
|
if (info->schemafile) {
|
||||||
schema = testQEMUSchemaLoad(info->schemafile);
|
/* lookup and insert into cache if not found */
|
||||||
|
if (!g_hash_table_lookup_extended(info->qapiSchemaCache,
|
||||||
|
info->schemafile,
|
||||||
|
NULL, (void **) &schema)) {
|
||||||
|
schema = testQEMUSchemaLoad(info->schemafile);
|
||||||
|
g_hash_table_insert(info->qapiSchemaCache,
|
||||||
|
g_strdup(info->schemafile),
|
||||||
|
schema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* comment out with line comment to enable schema checking for non _CAPS tests
|
/* comment out with line comment to enable schema checking for non _CAPS tests
|
||||||
if (!schema)
|
if (!schema)
|
||||||
@ -779,6 +788,7 @@ mymain(void)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
g_autofree char *fakerootdir = NULL;
|
g_autofree char *fakerootdir = NULL;
|
||||||
g_autoptr(GHashTable) capslatest = NULL;
|
g_autoptr(GHashTable) capslatest = NULL;
|
||||||
|
g_autoptr(GHashTable) qapiSchemaCache = virHashNew((GDestroyNotify) virHashFree);
|
||||||
|
|
||||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||||
|
|
||||||
@ -872,6 +882,7 @@ mymain(void)
|
|||||||
static struct testQemuInfo info = { \
|
static struct testQemuInfo info = { \
|
||||||
.name = _name, \
|
.name = _name, \
|
||||||
}; \
|
}; \
|
||||||
|
info.qapiSchemaCache = qapiSchemaCache; \
|
||||||
if (testQemuInfoSetArgs(&info, capslatest, \
|
if (testQemuInfoSetArgs(&info, capslatest, \
|
||||||
__VA_ARGS__, ARG_END) < 0) \
|
__VA_ARGS__, ARG_END) < 0) \
|
||||||
return EXIT_FAILURE; \
|
return EXIT_FAILURE; \
|
||||||
|
@ -66,6 +66,7 @@ struct testQemuInfo {
|
|||||||
unsigned int parseFlags;
|
unsigned int parseFlags;
|
||||||
virArch arch;
|
virArch arch;
|
||||||
char *schemafile;
|
char *schemafile;
|
||||||
|
GHashTable *qapiSchemaCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
virCapsPtr testQemuCapsInit(void);
|
virCapsPtr testQemuCapsInit(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user