Changes in / [665edf40:d2fadeb]


Ignore:
Location:
benchmark/io/http
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/protocol.cfa

    r665edf40 rd2fadeb  
    55        #include <fcntl.h>
    66}
    7 
    8 #define xstr(s) str(s)
    9 #define str(s) #s
    107
    118#include <fstream.hfa>
     
    2421
    2522#define PLAINTEXT_1WRITE
    26 #define PLAINTEXT_MEMCPY
    2723#define PLAINTEXT_NOCOPY
    2824
     
    8985#if defined(PLAINTEXT_NOCOPY)
    9086int answer_plaintext( int fd ) {
    91         return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len); // +1 cause snprintf doesn't count nullterminator
    92 }
    93 #elif defined(PLAINTEXT_MEMCPY)
    94 #define TEXTSIZE 15
    95 int answer_plaintext( int fd ) {
    96         char text[] = "Hello, World!\n\n";
    97         char ts[] = xstr(TEXTSIZE) " \n\n";
    98         _Static_assert(sizeof(text) - 1 == TEXTSIZE);
    99         char buffer[512 + TEXTSIZE];
    100         char * it = buffer;
    101         memcpy(it, http_msgs[OK200]->msg, http_msgs[OK200]->len);
    102         it += http_msgs[OK200]->len;
    103         int len = http_msgs[OK200]->len;
    104         memcpy(it, ts, sizeof(ts) - 1);
    105         it += sizeof(ts) - 1;
    106         len += sizeof(ts) - 1;
    107         memcpy(it, text, TEXTSIZE);
    108         return answer(fd, buffer, len + TEXTSIZE);
     87        return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len + 1); // +1 cause snprintf doesn't count nullterminator
    10988}
    11089#elif defined(PLAINTEXT_1WRITE)
    11190int answer_plaintext( int fd ) {
    112         char text[] = "Hello, World!\n\n";
     91        char text[] = "Hello, World!\n";
    11392        char buffer[512 + sizeof(text)];
    11493        char * it = buffer;
     
    124103#else
    125104int answer_plaintext( int fd ) {
    126         char text[] = "Hello, World!\n\n";
     105        char text[] = "Hello, World!\n";
    127106        int ret = answer_header(fd, sizeof(text));
    128107        if( ret < 0 ) return ret;
     
    215194const char * original_http_msgs[] = {
    216195        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: ",
    217         "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n\n",
     196        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n",
    218197        "HTTP/1.1 400 Bad Request\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    219198        "HTTP/1.1 404 Not Found\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
  • benchmark/io/http/worker.cfa

    r665edf40 rd2fadeb  
    1818void ?{}( Worker & this ) {
    1919        size_t cli = rand() % options.clopts.cltr_cnt;
    20         ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli], 512000 };
     20        ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli] };
    2121        options.clopts.thrd_cnt[cli]++;
    2222        this.pipe[0] = -1;
Note: See TracChangeset for help on using the changeset viewer.