Skip to content

Commit

Permalink
cleanup of migration from old crufty code
Browse files Browse the repository at this point in the history
  • Loading branch information
ingenthr committed Jun 20, 2009
1 parent b97bb15 commit 6dd2f83
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -16,3 +16,5 @@ config.status
libmemc.o
main.o
stamp-h1
memcachetest
metrics.o
4 changes: 2 additions & 2 deletions Makefile.am
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = testclient
bin_PROGRAMS = memcachetest

testclient_SOURCES = main.c libmemc.c libmemc.h boxmuller.c metrics.c
memcachetest_SOURCES = main.c libmemc.c libmemc.h boxmuller.c metrics.c

1 change: 1 addition & 0 deletions libmemc.c
Expand Up @@ -39,6 +39,7 @@
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <sys/uio.h>

struct Server {
int sock;
Expand Down
6 changes: 3 additions & 3 deletions main.c
Expand Up @@ -722,7 +722,7 @@ static int test(struct report *rep) {
fflush(stderr);
}
hrtime_t delta;
size_t size;
size_t size = 0;
hrtime_t start = gethrtime();
void *data = memcached_get_wrapper(connection, item.key,
item.keylen, &size);
Expand Down Expand Up @@ -901,7 +901,7 @@ static int load_keys(const char *fname) {

#else
keyarray = malloc(st.st_size);
size_t offset;
size_t offset = 0;
ssize_t nr;
do {
nr = read(fileno(fp), keyarray + offset, st.st_size - offset);
Expand Down Expand Up @@ -1252,7 +1252,7 @@ int main(int argc, char **argv) {

printf("Get operations:\n");
printf(" #of ops. min max avg max90th max95th\n");
printf("%13d", results->success_count);
printf("%13ld", results->success_count);
printf("%11.11s", hrtime2text(results->min_result, tmin, sizeof (tmin)));
printf("%11.11s", hrtime2text(results->max_result, tmax, sizeof (tmax)));
printf("%11.11s", hrtime2text(results->average, tavg, sizeof(tavg)));
Expand Down
11 changes: 2 additions & 9 deletions metrics.c
Expand Up @@ -69,12 +69,6 @@ struct TxnRunStatus {
};


struct TxnResult {
hrtime_t respTime;
struct TxnResult* left;
struct TxnResult* right;
};

static void insert(struct TxnResult** root, struct TxnResult* item) {
if (*root == NULL) {
*root = item;
Expand Down Expand Up @@ -199,10 +193,9 @@ static hrtime_t calc_average(struct TxnResult* a) {
* External interface
*/
void record_tx(enum TxnType tx_type, hrtime_t time) {
struct TxnResult new_txn { .respTme = time, .left = NULL, .right = NULL };

struct TxnResult* new_txn = calloc(1, sizeof(struct TxnResult));
pthread_mutex_lock(&lock);
insert(&txn_list_first, create_txn(&new_txn));
insert(&txn_list_first, create_txn(new_txn));
pthread_mutex_unlock(&lock);
txCntStdy[tx_type]++;
}
Expand Down
7 changes: 7 additions & 0 deletions metrics.h
Expand Up @@ -68,6 +68,13 @@ void record_tx(enum TxnType, hrtime_t);
void record_error(enum TxnType, hrtime_t);
struct ResultMetrics *calc_metrics(enum TxnType tx_type);

struct TxnResult {
hrtime_t respTime;
struct TxnResult * next;
struct TxnResult* left;
struct TxnResult* right;
};

struct ResultMetrics {
hrtime_t max_result;
hrtime_t min_result;
Expand Down

0 comments on commit 6dd2f83

Please sign in to comment.