Changeset 187fdb8


Ignore:
Timestamp:
Feb 25, 2021, 2:17:07 PM (8 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
ed2cb3c
Parents:
2caed18
Message:

Optim 60% to plaintext webserver by doing 1 write instead of 2.

Location:
benchmark/io/http
Files:
3 edited

Legend:

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

    r2caed18 r187fdb8  
    7979}
    8080
    81 int answer_plain( int fd, char buffer[], size_t size ) {
    82         int ret = answer_header(fd, size);
     81#define PLAINTEXT_1WRITE
     82#if defined(PLAINTEXT_1WRITE)
     83int answer_plaintext( int fd ) {
     84        char text[] = "Hello, World!\n";
     85        char buffer[512 + sizeof(text)];
     86        char * it = buffer;
     87        memcpy(it, http_msgs[OK200]->msg, http_msgs[OK200]->len);
     88        it += http_msgs[OK200]->len;
     89        int len = http_msgs[OK200]->len;
     90        int r = snprintf(it, 512 - len, "%d \n\n", sizeof(text));
     91        it += r;
     92        len += r;
     93        memcpy(it, text, sizeof(text));
     94        return answer(fd, buffer, len + sizeof(text));
     95}
     96#else
     97int answer_plaintext( int fd ) {
     98        char text[] = "Hello, World!\n";
     99        int ret = answer_header(fd, sizeof(text));
    83100        if( ret < 0 ) return ret;
    84         return answer(fd, buffer, size);
    85 }
     101        return answer(fd, text, sizeof(text));
     102}
     103#endif
    86104
    87105int answer_empty( int fd ) {
  • benchmark/io/http/protocol.hfa

    r2caed18 r187fdb8  
    1616int answer_error( int fd, HttpCode code );
    1717int answer_header( int fd, size_t size );
    18 int answer_plain( int fd, char buffer [], size_t size );
     18int answer_plaintext( int fd );
    1919int answer_empty( int fd );
    2020
  • benchmark/io/http/worker.cfa

    r2caed18 r187fdb8  
    7272                                if( options.log ) sout | "=== Request for /plaintext ===";
    7373
    74                                 char text[] = "Hello, World!\n";
    75 
    76                                 // Send the header
    77                                 int ret = answer_plain(fd, text, sizeof(text));
     74                                int ret = answer_plaintext(fd);
    7875                                if( ret == -ECONNRESET ) break REQUEST;
    7976
Note: See TracChangeset for help on using the changeset viewer.