Skip to content

Commit d84e70b

Browse files
authored
migrating minifier competition to new API (simdjson#597)
* Migrating minifiercompetition to new API.
1 parent 7ff0345 commit d84e70b

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

‎benchmark/minifiercompetition.cpp‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,16 @@ int main(int argc, char *argv[]) {
145145
.is_valid(),
146146
true, memcpy(buffer, mini_buffer, p.size()), repeat, volume, !just_data);
147147

148-
simdjson::ParsedJson pj;
149-
bool is_alloc_ok = pj.allocate_capacity(p.size(), 1024);
150-
if (!is_alloc_ok) {
151-
fprintf(stderr, "failed to allocate memory\n");
152-
return EXIT_FAILURE;
153-
}
148+
simdjson::document::parser parser;
154149
bool automated_reallocation = false;
155150
BEST_TIME("simdjson orig",
156-
simdjson::json_parse((const uint8_t *)buffer, p.size(), pj,
157-
automated_reallocation),
151+
parser.parse((const uint8_t *)buffer, p.size(),
152+
automated_reallocation).error(),
158153
simdjson::SUCCESS, memcpy(buffer, p.data(), p.size()), repeat, volume,
159154
!just_data);
160-
161-
simdjson::ParsedJson pj2;
162-
bool is_alloc_ok2 = pj2.allocate_capacity(p.size(), 1024);
163-
if (!is_alloc_ok2) {
164-
fprintf(stderr, "failed to allocate memory\n");
165-
return EXIT_FAILURE;
166-
}
167-
automated_reallocation = false;
168155
BEST_TIME("simdjson despaced",
169-
simdjson::json_parse((const uint8_t *)buffer, minisize, pj2,
170-
automated_reallocation),
156+
parser.parse((const uint8_t *)buffer, minisize,
157+
automated_reallocation).error(),
171158
simdjson::SUCCESS, memcpy(buffer, mini_buffer, p.size()), repeat, volume,
172159
!just_data);
173160

0 commit comments

Comments
 (0)