mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 08:34:39 +08:00
Update serialize.cc
This commit is contained in:
@@ -27,7 +27,7 @@ void showtime(const char *name, std::function<void ()> doit)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
using MapType = phmap::parallel_flat_hash_map<bitset<42>, int>;
|
using MapType = phmap::flat_hash_map<bitset<42>, int>;
|
||||||
MapType table;
|
MapType table;
|
||||||
const int num_items = 100000000;
|
const int num_items = 100000000;
|
||||||
|
|
||||||
@@ -50,18 +50,18 @@ int main()
|
|||||||
// cerealize and save data
|
// cerealize and save data
|
||||||
// -----------------------
|
// -----------------------
|
||||||
showtime("serialize", [&table]() {
|
showtime("serialize", [&table]() {
|
||||||
ofstream os("z:\out.cereal", ios::binary);
|
ofstream os("out.cereal", ios::binary);
|
||||||
cereal::BinaryOutputArchive archive(os);
|
cereal::BinaryOutputArchive archive(os);
|
||||||
archive(table.size());
|
archive(table.size());
|
||||||
archive(table);
|
archive(table);
|
||||||
});
|
});
|
||||||
|
|
||||||
MapType().swap(table);
|
MapType().swap(table); // make sure table is newly created
|
||||||
|
|
||||||
// deserialize
|
// deserialize
|
||||||
// -----------
|
// -----------
|
||||||
showtime("deserialize", [&table]() {
|
showtime("deserialize", [&table]() {
|
||||||
ifstream is("z:\out.cereal", ios::binary);
|
ifstream is("out.cereal", ios::binary);
|
||||||
cereal::BinaryInputArchive archive_in(is);
|
cereal::BinaryInputArchive archive_in(is);
|
||||||
size_t table_size;
|
size_t table_size;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user