aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-09 18:03:03 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-09 18:03:03 +0000
commit380d6d885e12803bd972d47812e093f78ee859f8 (patch)
treea550ca50a4d42512c6b0d883ca4d33fdd82589ca /src/ats
parentdb718fae66b0f4093730cac19b5d19d026ebf46e (diff)
downloadgnunet-380d6d885e12803bd972d47812e093f78ee859f8.tar.gz
gnunet-380d6d885e12803bd972d47812e093f78ee859f8.zip
clean up for addresses and modification to perf to get values in averaging
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c307
-rw-r--r--src/ats/perf_ats_solver.c270
2 files changed, 85 insertions, 492 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 8b5413b92..6b8f13a1b 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -1355,312 +1355,6 @@ GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
1355} 1355}
1356 1356
1357 1357
1358static int
1359eval_count_active_it (void *cls,
1360 const struct GNUNET_PeerIdentity *id,
1361 void *obj)
1362{
1363 int *request_fulfilled = cls;
1364 struct ATS_Address *addr = obj;
1365
1366 if (GNUNET_YES == addr->active)
1367 (*request_fulfilled) = GNUNET_YES;
1368
1369 if (*request_fulfilled == GNUNET_YES)
1370 return GNUNET_NO;
1371 else
1372 return GNUNET_YES;
1373}
1374
1375
1376/**
1377 * Summary context
1378 */
1379struct SummaryContext
1380{
1381 /**
1382 * Sum of the utilized inbound bandwidth per network
1383 */
1384 unsigned long long bandwidth_in_assigned[GNUNET_ATS_NetworkTypeCount];
1385
1386 /**
1387 * Sum of the utilized outbound bandwidth per network
1388 */
1389 unsigned long long bandwidth_out_assigned[GNUNET_ATS_NetworkTypeCount];
1390
1391 /**
1392 * Sum addresses within a network
1393 */
1394 unsigned int addresses_in_network[GNUNET_ATS_NetworkTypeCount];
1395};
1396
1397
1398static int
1399eval_sum_bw_used (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
1400{
1401 struct SummaryContext *ctx = cls;
1402 struct ATS_Address *addr = obj;
1403 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
1404 int net;
1405 int c;
1406
1407 if (GNUNET_YES == addr->active)
1408 {
1409 net = get_performance_info (addr, GNUNET_ATS_NETWORK_TYPE);
1410 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1411 {
1412 if (net == networks[c])
1413 {
1414 ctx->addresses_in_network[c] ++;
1415 ctx->bandwidth_in_assigned[c] += ntohl (addr->assigned_bw_in.value__);
1416 ctx->bandwidth_out_assigned[c] += ntohl (addr->assigned_bw_out.value__);
1417 }
1418 }
1419 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1420 "Active address in %s with (in/out) %u/%u Bps\n",
1421 GNUNET_ATS_print_network_type (net),
1422 (unsigned int) ntohl (addr->assigned_bw_in.value__),
1423 (unsigned int) ntohl (addr->assigned_bw_out.value__));
1424 }
1425 return GNUNET_OK;
1426}
1427
1428
1429/**
1430 * Summary context
1431 */
1432struct RelativityContext
1433{
1434
1435 struct GAS_Addresses_Handle *ah;
1436};
1437
1438
1439static int
1440find_active_address (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
1441{
1442 struct ATS_Address **res = cls;
1443 struct ATS_Address *addr = obj;
1444
1445 if (GNUNET_YES == addr->active)
1446 (*res) = addr;
1447
1448 if (NULL != (*res))
1449 return GNUNET_NO;
1450 else
1451 return GNUNET_YES;
1452}
1453
1454/**
1455 * Evaluate current bandwidth assignment
1456 *
1457 * @param ah address handle
1458 */
1459void
1460GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah)
1461{
1462#if 0
1463 struct GAS_Addresses_Suggestion_Requests *cur;
1464 struct GAS_Addresses_Preference_Clients *pcur;
1465 int c;
1466
1467 float quality_requests_fulfilled = 0.0;
1468 float quality_bandwidth_utilization[GNUNET_ATS_NetworkTypeCount];
1469 float quality_bandwidth_utilization_total = 0.0;
1470 float quality_application_requirements = 0.0;
1471 float guq = 0.0;
1472
1473 int include_requests;
1474 int include_utilization;
1475 int include_requirements;
1476
1477 /* Variable related to requests */
1478 unsigned int requests_pending;
1479 unsigned int requests_fulfilled;
1480 unsigned int request_active;
1481
1482 /* Variable related to utilization */
1483 struct SummaryContext sum;
1484 struct ATS_Address *active_address;
1485 int network_count;
1486
1487 /* Variables for preferences */
1488 int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType;
1489 double pref_val;
1490 double prop_val;
1491 const double *norm_values;
1492 double prefs_fulfill[GNUNET_ATS_PreferenceCount];
1493 int prefs_clients[GNUNET_ATS_PreferenceCount];
1494 int rels;
1495
1496 GNUNET_assert (NULL != ah);
1497 GNUNET_assert (NULL != ah->addresses);
1498
1499 requests_pending = 0;
1500 requests_fulfilled = 0;
1501 /* 1) How many requests could be fulfilled? */
1502 for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next)
1503 {
1504 request_active = GNUNET_NO;
1505 GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses,
1506 &cur->id, &eval_count_active_it, &request_active);
1507 if (GNUNET_YES == request_active)
1508 requests_fulfilled ++;
1509 requests_pending ++;
1510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s': %u pending requests, %s\n",
1511 GNUNET_i2s (&cur->id),
1512 requests_pending,
1513 (GNUNET_YES == request_active) ? "active adress" : "no active address");
1514
1515 }
1516 if (requests_pending > 0)
1517 {
1518 quality_requests_fulfilled = (float) requests_fulfilled / requests_pending;
1519 include_requests = GNUNET_YES;
1520 }
1521 else
1522 {
1523 quality_requests_fulfilled = 0.0;
1524 include_requests = GNUNET_NO;
1525 }
1526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u pending requests, %u requests fullfilled\n",
1527 requests_pending, requests_fulfilled);
1528
1529 /* 2) How well is bandwidth utilized? */
1530 network_count = 0;
1531 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1532 {
1533 quality_bandwidth_utilization[c] = 0.0;
1534 sum.addresses_in_network[c] = 0;
1535 sum.bandwidth_in_assigned[c] = 0;
1536 sum.bandwidth_out_assigned[c] = 0;
1537 }
1538 GNUNET_CONTAINER_multipeermap_iterate(ah->addresses,
1539 &eval_sum_bw_used, &sum);
1540 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1541 {
1542 quality_bandwidth_utilization[c] = (((float)sum.bandwidth_out_assigned[c] / ah->env.out_quota[c]) +
1543 ((float)sum.bandwidth_in_assigned[c] / ah->env.in_quota[c])) / 2;
1544
1545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Utilization for network `%s': %f\n",
1546 GNUNET_ATS_print_network_type(ah->env.networks[c]),
1547 quality_bandwidth_utilization[c]);
1548 if (sum.addresses_in_network[c] > 0)
1549 {
1550 quality_bandwidth_utilization_total += quality_bandwidth_utilization[c];
1551 network_count ++;
1552 }
1553 }
1554 if (0 < network_count)
1555 {
1556 quality_bandwidth_utilization_total /= network_count;
1557 include_utilization = GNUNET_YES;
1558 }
1559 else
1560 {
1561 quality_bandwidth_utilization_total = 0.0;
1562 include_utilization = GNUNET_NO;
1563 }
1564
1565 /* 3) How well does selection match application requirements */
1566 if (0 == ah->pref_clients)
1567 {
1568 include_requirements = 0;
1569 }
1570 else
1571 {
1572 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1573 {
1574 prefs_fulfill[c] = 0.0;
1575 prefs_clients[c] = 0;
1576 }
1577
1578 for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next)
1579 {
1580 active_address = NULL;
1581 GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses,
1582 &cur->id, &find_active_address, &active_address);
1583
1584 for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next)
1585 {
1586 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1587 {
1588 if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
1589 continue;
1590 pref_val = GAS_normalization_get_preferences_by_client (pcur->client, &cur->id, prefs[c]);
1591 if (-1.0 == pref_val)
1592 {
1593 GNUNET_break (0);
1594 continue;
1595 }
1596
1597 if (DEFAULT_REL_PREFERENCE == pref_val)
1598 {
1599 /* Default preference value */
1600 continue;
1601 }
1602
1603 if (NULL != active_address)
1604 {
1605 norm_values = GAS_normalization_get_properties (active_address);
1606 prop_val = norm_values[c];
1607 if ((norm_values[c] <= 1.0) || (norm_values[c] >= 2.0))
1608 prop_val = DEFAULT_REL_QUALITY;
1609 }
1610 else
1611 {
1612 prop_val = DEFAULT_REL_QUALITY;
1613 }
1614
1615 /* We now have preference values [1..2] and properties [1..2] */
1616
1617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u Client %p, Peer %s Property %s: pref: %.3f prop %.3f \n",
1618 c,
1619 pcur->client,
1620 GNUNET_i2s (&cur->id),
1621 GNUNET_ATS_print_preference_type(prefs[c]),
1622 pref_val,
1623 prop_val);
1624
1625 prefs_fulfill[c] += (pref_val * prop_val) / 2;
1626 prefs_clients[c] ++;
1627 }
1628 }
1629 }
1630 rels = 0;
1631 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1632 {
1633 if (0 < prefs_clients[c])
1634 {
1635 prefs_fulfill[c] /= prefs_clients[c];
1636 rels ++;
1637 quality_application_requirements += prefs_fulfill[c];
1638 }
1639 }
1640 if (rels > 0)
1641 quality_application_requirements /= rels;
1642 else
1643 quality_application_requirements = 0.0;
1644
1645 include_requirements = 1;
1646 }
1647 /* GUQ */
1648
1649 if (include_requests + include_utilization + include_requirements > 0)
1650 guq = (quality_requests_fulfilled + quality_bandwidth_utilization_total + quality_application_requirements) /
1651 (include_requests + include_utilization + include_requirements);
1652 else
1653 guq = 0.0;
1654
1655 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1656 "Requests fulfilled %.3f bandwidth utilized %.3f application preferences met %.3f => %.3f\n",
1657 quality_requests_fulfilled,
1658 quality_bandwidth_utilization_total,
1659 quality_application_requirements,
1660 guq);
1661#endif
1662}
1663
1664/** 1358/**
1665 * Solver information callback 1359 * Solver information callback
1666 * 1360 *
@@ -1753,7 +1447,6 @@ solver_info_cb (void *cls,
1753 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1447 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1754 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", 1448 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
1755 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 1449 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
1756 GAS_addresses_evaluate_assignment (cls);
1757 return; 1450 return;
1758 default: 1451 default:
1759 break; 1452 break;
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 025fab721..066a7d4ec 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -38,47 +38,6 @@
38#define DEFAULT_ADDRESSES 10 38#define DEFAULT_ADDRESSES 10
39#define DEFAULT_ATS_COUNT 2 39#define DEFAULT_ATS_COUNT 2
40 40
41#define GNUPLOT_PROP_TEMPLATE "#!/usr/bin/gnuplot \n" \
42"set datafile separator ';' \n" \
43"set title \"Execution time Proportional solver \" \n" \
44"set xlabel \"Number of peers\" \n" \
45"set ylabel \"Execution time in us\" \n" \
46"set grid \n"
47
48#define GNUPLOT_PROP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
49"set datafile separator ';' \n" \
50"set title \"Execution time Proportional solver with updated problem\" \n" \
51"set xlabel \"Number of peers\" \n" \
52"set ylabel \"Execution time in us\" \n" \
53"set grid \n"
54
55#define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \
56"set datafile separator ';' \n" \
57"set title \"Execution time MLP solver \" \n" \
58"set xlabel \"Number of peers\" \n" \
59"set ylabel \"Execution time in us\" \n" \
60"set grid \n"
61
62#define GNUPLOT_MLP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
63"set datafile separator ';' \n" \
64"set title \"Execution time MLP solver with updated problem\" \n" \
65"set xlabel \"Number of peers\" \n" \
66"set ylabel \"Execution time in us\" \n" \
67"set grid \n"
68
69#define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \
70"set datafile separator ';' \n" \
71"set title \"Execution time RIL solver \" \n" \
72"set xlabel \"Number of peers\" \n" \
73"set ylabel \"Execution time in us\" \n" \
74"set grid \n"
75
76#define GNUPLOT_RIL_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
77"set datafile separator ';' \n" \
78"set title \"Execution time RIL solver with updated problem\" \n" \
79"set xlabel \"Number of peers\" \n" \
80"set ylabel \"Execution time in us\" \n" \
81"set grid \n"
82 41
83/** 42/**
84 * Handle for ATS address component 43 * Handle for ATS address component
@@ -173,7 +132,7 @@ struct PerfHandle
173 /** 132 /**
174 * Create gnuplot file 133 * Create gnuplot file
175 */ 134 */
176 int create_plot; 135 int create_datafile;
177 136
178 /** 137 /**
179 * Measure updates 138 * Measure updates
@@ -211,6 +170,7 @@ struct PerfHandle
211 */ 170 */
212struct Iteration 171struct Iteration
213{ 172{
173 struct Result **results_array;
214 /** 174 /**
215 * Head of the linked list 175 * Head of the linked list
216 */ 176 */
@@ -630,6 +590,7 @@ solver_info_cb (void *cls,
630 /* Create new result */ 590 /* Create new result */
631 tmp = GNUNET_new (struct Result); 591 tmp = GNUNET_new (struct Result);
632 ph.current_result = tmp; 592 ph.current_result = tmp;
593 ph.iterations_results[ph.current_iteration-1].results_array[ph.current_p -1] = tmp;
633 GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head, 594 GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head,
634 ph.iterations_results[ph.current_iteration-1].result_tail, tmp); 595 ph.iterations_results[ph.current_iteration-1].result_tail, tmp);
635 ph.current_result->addresses = ph.current_a; 596 ph.current_result->addresses = ph.current_a;
@@ -810,122 +771,6 @@ solver_info_cb (void *cls,
810 } 771 }
811} 772}
812 773
813static void
814write_gnuplot_script (char * data_fn, int iteration, int full)
815{
816 struct GNUNET_DISK_FileHandle *f;
817 char * gfn;
818 char *data;
819 char *iter_text;
820 char *template;
821
822 /* Write header */
823 switch (ph.ats_mode) {
824 case MODE_PROPORTIONAL:
825 if (GNUNET_YES == full)
826 template = GNUPLOT_PROP_TEMPLATE;
827 else
828 template = GNUPLOT_PROP_UPDATE_TEMPLATE;
829 break;
830 case MODE_MLP:
831 if (GNUNET_YES == full)
832 template = GNUPLOT_MLP_TEMPLATE;
833 else
834 template = GNUPLOT_MLP_UPDATE_TEMPLATE;
835 break;
836 case MODE_RIL:
837 if (GNUNET_YES == full)
838 template = GNUPLOT_RIL_TEMPLATE;
839 else
840 template = GNUPLOT_RIL_UPDATE_TEMPLATE;
841 break;
842 default:
843 GNUNET_break (0);
844 return;
845 }
846 if (-1 == iteration)
847 GNUNET_asprintf (&iter_text, "%s_%u", "avg",ph.total_iterations);
848 else
849 GNUNET_asprintf (&iter_text, "%u", iteration);
850 if (GNUNET_YES == full)
851 {
852 GNUNET_asprintf (&gfn, "perf_%s_full_%s-%u_%u_%u.gnuplot",
853 ph.ats_string,
854 iter_text,
855 ph.N_peers_start,
856 ph.N_peers_end,
857 ph.N_address);
858 }
859 else
860 {
861 GNUNET_asprintf (&gfn, "perf_%s_updat_%s-%u_%u_%u.gnuplot",
862 ph.ats_string,
863 iter_text,
864 ph.N_peers_start,
865 ph.N_peers_end,
866 ph.N_address);
867 }
868 GNUNET_free (iter_text);
869
870 f = GNUNET_DISK_file_open (gfn,
871 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
872 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
873 if (NULL == f)
874 {
875 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
876 GNUNET_free (gfn);
877 return;
878 }
879
880 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, template, strlen(template)))
881 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
882
883 data = NULL;
884 if (MODE_PROPORTIONAL == ph.ats_mode)
885 {
886 GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
887 "pause -1",
888 data_fn, 3);
889 }
890 else if (MODE_MLP == ph.ats_mode)
891 {
892 GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve',\\\n" \
893 "'%s' using 1:%u with lines title 'Time to setup',\\\n"
894 "'%s' using 1:%u with lines title 'Time to solve LP',\\\n"
895 "'%s' using 1:%u with lines title 'Total time to solve MLP'\n" \
896 "pause -1",
897 data_fn, 3,
898 data_fn, 4,
899 data_fn, 5,
900 data_fn, 6);
901 }
902 else if (MODE_RIL == ph.ats_mode)
903 {
904 GNUNET_asprintf (&data,
905 "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
906 "pause -1",
907 data_fn, 3);
908 }
909
910 if ((NULL != data) &&
911 (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen(data))))
912 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
913 "Cannot write data to plot file `%s'\n",
914 gfn);
915 GNUNET_free_non_null (data);
916
917 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
918 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
919 "Cannot close gnuplot file `%s'\n",
920 gfn);
921 else
922 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
923 "Data successfully written to plot file `%s'\n",
924 gfn);
925 GNUNET_free (gfn);
926
927}
928
929/** 774/**
930 * Evaluate results for a specific iteration 775 * Evaluate results for a specific iteration
931 * 776 *
@@ -953,7 +798,7 @@ evaluate (int iteration)
953 798
954 data_fn_full = NULL; 799 data_fn_full = NULL;
955 800
956 if (ph.create_plot) 801 if (ph.create_datafile)
957 { 802 {
958 if (-1 == iteration) 803 if (-1 == iteration)
959 GNUNET_asprintf (&iter_text, "%s", "avg"); 804 GNUNET_asprintf (&iter_text, "%s", "avg");
@@ -983,11 +828,10 @@ evaluate (int iteration)
983 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 828 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
984 "Cannot write data to log file `%s'\n", 829 "Cannot write data to log file `%s'\n",
985 data_fn_full); 830 data_fn_full);
986 write_gnuplot_script (data_fn_full, iteration, GNUNET_YES);
987 } 831 }
988 832
989 data_fn_update = NULL; 833 data_fn_update = NULL;
990 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) 834 if ((ph.create_datafile) && (GNUNET_YES == ph.measure_updates))
991 { 835 {
992 if (-1 == iteration) 836 if (-1 == iteration)
993 GNUNET_asprintf (&iter_text, "%s", "avg"); 837 GNUNET_asprintf (&iter_text, "%s", "avg");
@@ -1018,7 +862,6 @@ evaluate (int iteration)
1018 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 862 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1019 "Cannot write data to log file `%s'\n", 863 "Cannot write data to log file `%s'\n",
1020 data_fn_update); 864 data_fn_update);
1021 write_gnuplot_script (data_fn_update, iteration, GNUNET_NO);
1022 } 865 }
1023 866
1024 next = ph.iterations_results[ph.current_iteration -1].result_head; 867 next = ph.iterations_results[ph.current_iteration -1].result_head;
@@ -1123,7 +966,7 @@ evaluate (int iteration)
1123 GNUNET_asprintf (&str_d_mlp, "-1"); 966 GNUNET_asprintf (&str_d_mlp, "-1");
1124 967
1125 data = NULL; 968 data = NULL;
1126 if (GNUNET_YES == ph.create_plot) 969 if (GNUNET_YES == ph.create_datafile)
1127 { 970 {
1128 971
1129 GNUNET_asprintf (&data, 972 GNUNET_asprintf (&data,
@@ -1156,7 +999,7 @@ evaluate (int iteration)
1156 999
1157 GNUNET_CONTAINER_DLL_remove (ph.iterations_results[ph.current_iteration-1].result_head, 1000 GNUNET_CONTAINER_DLL_remove (ph.iterations_results[ph.current_iteration-1].result_head,
1158 ph.iterations_results[ph.current_iteration-1].result_tail, cur); 1001 ph.iterations_results[ph.current_iteration-1].result_tail, cur);
1159 GNUNET_free (cur); 1002 //GNUNET_free (cur);
1160 } 1003 }
1161 1004
1162 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) 1005 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
@@ -1176,8 +1019,8 @@ evaluate (int iteration)
1176static void 1019static void
1177evaluate_average (void) 1020evaluate_average (void)
1178{ 1021{
1179 int c_o; 1022 int c_iteration;
1180 int c_i; 1023 int c_peer;
1181 1024
1182 struct GNUNET_DISK_FileHandle *f_full; 1025 struct GNUNET_DISK_FileHandle *f_full;
1183 struct GNUNET_DISK_FileHandle *f_update; 1026 struct GNUNET_DISK_FileHandle *f_update;
@@ -1185,17 +1028,18 @@ evaluate_average (void)
1185 char * data_fn_full; 1028 char * data_fn_full;
1186 char * data_fn_update; 1029 char * data_fn_update;
1187 char * data; 1030 char * data;
1031/*
1188 char * str_d_total; 1032 char * str_d_total;
1189 char * str_d_setup; 1033 char * str_d_setup;
1190 char * str_d_lp; 1034 char * str_d_lp;
1191 char * str_d_mlp; 1035 char * str_d_mlp;
1192 1036*/
1193 f_full = NULL; 1037 f_full = NULL;
1194 f_update = NULL; 1038 f_update = NULL;
1195 1039
1196 data_fn_full = NULL; 1040 data_fn_full = NULL;
1197 1041
1198 if (ph.create_plot) 1042 if (ph.create_datafile)
1199 { 1043 {
1200 GNUNET_asprintf (&data_fn_full, 1044 GNUNET_asprintf (&data_fn_full,
1201 "perf_%s_full_avg_%u-%u_%u_%u.data", 1045 "perf_%s_full_avg_%u-%u_%u_%u.data",
@@ -1204,6 +1048,10 @@ evaluate_average (void)
1204 ph.N_peers_start, 1048 ph.N_peers_start,
1205 ph.N_peers_end, 1049 ph.N_peers_end,
1206 ph.N_address); 1050 ph.N_address);
1051 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1052 "Using data file `%s'\n",
1053 data_fn_full);
1054
1207 f_full = GNUNET_DISK_file_open (data_fn_full, 1055 f_full = GNUNET_DISK_file_open (data_fn_full,
1208 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 1056 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
1209 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 1057 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
@@ -1215,16 +1063,20 @@ evaluate_average (void)
1215 GNUNET_free (data_fn_full); 1063 GNUNET_free (data_fn_full);
1216 return; 1064 return;
1217 } 1065 }
1066
1067 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1068 "Using update data file `%s'\n",
1069 data_fn_full);
1070
1218 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; 1071 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1219 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) 1072 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
1220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1073 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1221 "Cannot write data to log file `%s'\n", 1074 "Cannot write data to log file `%s'\n",
1222 data_fn_full); 1075 data_fn_full);
1223 write_gnuplot_script (data_fn_full, -1, GNUNET_YES);
1224 } 1076 }
1225 1077
1226 data_fn_update = NULL; 1078 data_fn_update = NULL;
1227 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) 1079 if ((ph.create_datafile) && (GNUNET_YES == ph.measure_updates))
1228 { 1080 {
1229 GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data", 1081 GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data",
1230 ph.ats_string, 1082 ph.ats_string,
@@ -1245,14 +1097,59 @@ evaluate_average (void)
1245 GNUNET_free (data_fn_full); 1097 GNUNET_free (data_fn_full);
1246 return; 1098 return;
1247 } 1099 }
1100
1101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1102 "Using update data file `%s'\n",
1103 data_fn_update);
1104
1248 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; 1105 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1249 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) 1106 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1251 "Cannot write data to log file `%s'\n", 1108 "Cannot write data to log file `%s'\n",
1252 data_fn_update); 1109 data_fn_update);
1253 write_gnuplot_script (data_fn_update, -1, GNUNET_NO);
1254 } 1110 }
1255 1111
1112 /* NEW log */
1113 for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++)
1114 {
1115 char * data_str;
1116 char * data_tmp;
1117 GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address);
1118 for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++)
1119 {
1120 struct Result *cur_res;
1121
1122 cur_res = ph.iterations_results[c_iteration].results_array[c_peer -1];
1123 fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses);
1124 fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us);
1125
1126 data_tmp = GNUNET_strdup (data_str);
1127 GNUNET_free (data_str);
1128 GNUNET_asprintf (&data_str, "%s;%llu", data_tmp, cur_res->d_total.rel_value_us);
1129 GNUNET_free (data_tmp);
1130 }
1131 data_tmp = GNUNET_strdup (data_str);
1132 GNUNET_free (data_str);
1133 GNUNET_asprintf (&data_str, "%s\n", data_tmp);
1134 GNUNET_free (data_tmp);
1135
1136 fprintf (stderr, "Result: %s\n", data_str);
1137 GNUNET_DISK_file_write (f_full, data_str, strlen(data_str));
1138 GNUNET_free (data_str);
1139 }
1140 /* NEW log */
1141
1142 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1143 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1144 data_fn_full);
1145 GNUNET_free_non_null (data_fn_full);
1146
1147 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1148 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1149 data_fn_update);
1150 GNUNET_free_non_null (data_fn_update);
1151
1152#if 0
1256 for (c_o = 0; c_o < 2; c_o++) 1153 for (c_o = 0; c_o < 2; c_o++)
1257 { 1154 {
1258 if (0 == c_o) 1155 if (0 == c_o)
@@ -1350,7 +1247,7 @@ evaluate_average (void)
1350 GNUNET_asprintf (&str_d_mlp, "-1"); 1247 GNUNET_asprintf (&str_d_mlp, "-1");
1351 1248
1352 data = NULL; 1249 data = NULL;
1353 if (GNUNET_YES == ph.create_plot) 1250 if (GNUNET_YES == ph.create_datafile)
1354 { 1251 {
1355 GNUNET_asprintf (&data, 1252 GNUNET_asprintf (&data,
1356 "%u;%u;%s;%s;%s;%s\n", 1253 "%u;%u;%s;%s;%s;%s\n",
@@ -1382,16 +1279,8 @@ evaluate_average (void)
1382 GNUNET_free_non_null (str_d_mlp); 1279 GNUNET_free_non_null (str_d_mlp);
1383 } 1280 }
1384 } 1281 }
1282#endif
1385 1283
1386 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1387 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1388 data_fn_full);
1389 GNUNET_free_non_null (data_fn_full);
1390
1391 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1392 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1393 data_fn_update);
1394 GNUNET_free_non_null (data_fn_update);
1395} 1284}
1396 1285
1397/** 1286/**
@@ -1410,6 +1299,7 @@ perf_run_iteration (void)
1410 struct ATS_Address * cur_addr; 1299 struct ATS_Address * cur_addr;
1411 1300
1412 1301
1302 ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p) * sizeof (struct Result *));
1413 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); 1303 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
1414 for (cp = 0; cp < count_p; cp++) 1304 for (cp = 0; cp < count_p; cp++)
1415 perf_create_peer (cp); 1305 perf_create_peer (cp);
@@ -1527,6 +1417,7 @@ run (void *cls, char * const *args, const char *cfgfile,
1527 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; 1417 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
1528 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; 1418 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
1529 int c; 1419 int c;
1420 int c2;
1530 1421
1531 /* Extract test name */ 1422 /* Extract test name */
1532 if (NULL == (sep = (strstr (src_filename,".c")))) 1423 if (NULL == (sep = (strstr (src_filename,".c"))))
@@ -1677,6 +1568,15 @@ run (void *cls, char * const *args, const char *cfgfile,
1677 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string); 1568 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string);
1678 GNUNET_PLUGIN_unload (plugin, ph.solver); 1569 GNUNET_PLUGIN_unload (plugin, ph.solver);
1679 GNUNET_free (plugin); 1570 GNUNET_free (plugin);
1571 for (c = 0; c < ph.total_iterations; c++ )
1572 {
1573 for (c2 = ph.N_peers_start; c2 < ph.N_peers_end; c2++ )
1574 {
1575 GNUNET_free (ph.iterations_results[c].results_array[c2]);
1576 }
1577 GNUNET_free(ph.iterations_results[c].results_array);
1578
1579 }
1680 GNUNET_free (ph.iterations_results); 1580 GNUNET_free (ph.iterations_results);
1681 GNUNET_free (ph.averaged_full_result); 1581 GNUNET_free (ph.averaged_full_result);
1682 GNUNET_free (ph.averaged_update_result); 1582 GNUNET_free (ph.averaged_update_result);
@@ -1700,7 +1600,7 @@ main (int argc, char *argv[])
1700 ph.N_peers_end = 0; 1600 ph.N_peers_end = 0;
1701 ph.N_address = 0; 1601 ph.N_address = 0;
1702 ph.ats_string = NULL; 1602 ph.ats_string = NULL;
1703 ph.create_plot = GNUNET_NO; 1603 ph.create_datafile = GNUNET_NO;
1704 ph.measure_updates = GNUNET_NO; 1604 ph.measure_updates = GNUNET_NO;
1705 ph.total_iterations = 1; 1605 ph.total_iterations = 1;
1706 1606
@@ -1720,9 +1620,9 @@ main (int argc, char *argv[])
1720 { 'p', "percentage", NULL, 1620 { 'p', "percentage", NULL,
1721 gettext_noop ("update a fix percentage of addresses"), 1621 gettext_noop ("update a fix percentage of addresses"),
1722 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, 1622 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },
1723 { 'g', "gnuplot", NULL, 1623 { 'd', "data", NULL,
1724 gettext_noop ("create GNUplot file"), 1624 gettext_noop ("create data file"),
1725 0, &GNUNET_GETOPT_set_one, &ph.create_plot}, 1625 0, &GNUNET_GETOPT_set_one, &ph.create_datafile},
1726 { 'u', "update", NULL, 1626 { 'u', "update", NULL,
1727 gettext_noop ("measure updates"), 1627 gettext_noop ("measure updates"),
1728 0, &GNUNET_GETOPT_set_one, &ph.measure_updates}, 1628 0, &GNUNET_GETOPT_set_one, &ph.measure_updates},