diff options
| author | John Snow | 2015-05-22 20:13:44 +0200 |
|---|---|---|
| committer | John Snow | 2015-05-22 21:58:22 +0200 |
| commit | 5560b85a31e6f15a8841b66620d9497943094ee4 (patch) | |
| tree | 267c1f98fab3800dcdc936ebc66f565c9d4d8445 /tests | |
| parent | libqos/ahci: Swap memread/write with bufread/write (diff) | |
| download | qemu-5560b85a31e6f15a8841b66620d9497943094ee4.tar.gz qemu-5560b85a31e6f15a8841b66620d9497943094ee4.tar.xz qemu-5560b85a31e6f15a8841b66620d9497943094ee4.zip | |
qtest: pre-buffer hex nibs
Instead of converting each byte one-at-a-time and then sending each byte
over the wire, use sprintf() to pre-compute all of the hex nibs into a
single buffer, then send the entire buffer all at once.
This gives a moderate speed boost to memread() and memwrite() functions.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1431021095-7558-2-git-send-email-jsnow@redhat.com
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/libqtest.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c index 055aad69e0..e5188e0327 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -730,13 +730,15 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size) { const uint8_t *ptr = data; size_t i; + char *enc = g_malloc(2 * size + 1); - qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x", addr, size); for (i = 0; i < size; i++) { - qtest_sendf(s, "%02x", ptr[i]); + sprintf(&enc[i * 2], "%02x", ptr[i]); } - qtest_sendf(s, "\n"); + + qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x%s\n", addr, size, enc); qtest_rsp(s, 0); + g_free(enc); } void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size) |
