-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.cpp
More file actions
77 lines (56 loc) · 1.66 KB
/
Copy pathtable.cpp
File metadata and controls
77 lines (56 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "HashTable.h"
#include "files.h"
#include "Hashing.h"
extern "C" int64_t MurmurHash (const void *data_ptr, int len);
#define HASH_USED CRC32
int StressTest (Hash_t *table, config io_config)
{
file_info src = {};
int read = read_all_words (&src, io_config.input_file);
if (!read)
{
printf ("ERROR: Reading file failed!\n");
return READ_TEXT_FAILED;
}
type_t inserting = {};
for (int word = 0; word < src.elems_num; word++)
{
inserting.key = src.strs[word].text;
inserting.key_len = src.strs[word].len;
TableInsert (table, inserting, HASH_USED);
}
// for (int i = 0; i < table->capacity; i++)
// {
// List *list = (List *) GetElemByHash (table, i);
// printf ("%d; %d\n", i, list->size);
// }
for (int i = 0; i < 512; i++)
{
for (int word = 0; word < src.elems_num; word++)
{
volatile type_t find_res = TableFind (table, src.strs[word].text, src.strs[word].len, HASH_USED);
}
}
for (int word = 0; word < src.elems_num; word++)
{
// printf ("deleting |%.*s|\n", src.strs[word].len, src.strs[word].text);
TableDelete (table, src.strs[word].text, src.strs[word].len, HASH_USED);
}
DestrTable (table, ListDtor);
free_info (&src);
return 0;
}
int main (int argc, const char **argv)
{
config io_config = {};
get_params (argc, argv, &io_config);
Hash_t table = {};
int created = CreateTable (&table, io_config.table_len);
if (created)
{
DestrTable (&table, ListDtor);
return created;
}
StressTest (&table, io_config);
return 0;
}