4 #include "clave_fija.h"
6 #include "keymanager.h"
8 int main (int argc, char *argv[])
11 std::cout << "Uso: " << argv[0] << " <block size> <cantidad de altas> <cantidad de bajas>\n";
12 std::cout << "\tEl tamaño de bloque usado es 512*2^<block size>.\n";
16 int bloque = 128 << (atoi (argv[1]) + 2);
17 int altas = atoi (argv[2]);
18 int bajas = atoi (argv[3]);
20 KeyManager<std::string> km;
21 BTree tree ("test.idx", bloque, BTree::TYPE_UNIQUE, BTree::KEY_VARIABLE);
23 std::list<std::string> lst;
24 std::list<std::string>::iterator it;
26 Random::Strings (lst, altas);
28 double paltas = bajas / (double)(altas + bajas);
31 while (it != lst.end ()) {
34 double l = Random::Double (0.0f, 1.0f);
35 std::cout << l << " >= " << paltas << std::endl;
36 if (!km.Size() // si no tenemos claves agregadas, mejor que hagamos un alta
39 std::cout << "Clave Agregada " << sss << std::endl;
43 } catch (Exception *e) {
44 std::cout << e->Message () << std::endl;
48 /* Tengo que borrar una clave entre 0 e "i" de la lista
49 * porque son las que ya agregue. */
50 ClaveVariable c(km.GetRandom ());
55 std::cout << "Clave Borrada " << sss << std::endl;
56 } catch (Exception *e) {
57 std::cout << e->Message () << std::endl;
64 std::list <std::string> l = km.GetList ();
68 while (it != l.end ()) {
74 std::cout << "** Clave " << (*it) << " encontrada.\n";
78 std::cout << "** Clave " << (*it) << " NO encontrada.\n";
84 std::cout << "\n\n === Resultados ===\n";
85 std::cout << " Hist : " << bien << "\n";
86 std::cout << " Miss : " << mal << "\n";
87 std::cout << " Total : " << (bien+mal) << "\n";