Ignore:
Timestamp:
Feb 25, 2021, 2:17:07 PM (9 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.

File:
1 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 ) {
Note: See TracChangeset for help on using the changeset viewer.