You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2023/11/28 11:02:37 UTC

Re: [I] binding/python: rust std fs is slower than python fs [incubator-opendal]

Xuanwo commented on issue #3665:
URL: https://github.com/apache/incubator-opendal/issues/3665#issuecomment-1829591828

   I have the same result on with a C application:
   
   ```c
   #include <stdio.h>
   #include <stdlib.h>
   
   #define FILE_SIZE 64 * 1024 * 1024  // 64 MiB
   
   int main() {
       FILE *file;
       char *buffer;
       size_t result;
   
       file = fopen("/tmp/file", "rb");
       if (file == NULL) {
           fputs("Error opening file", stderr);
           return 1;
       }
   
       buffer = (char *)malloc(sizeof(char) * FILE_SIZE);
       if (buffer == NULL) {
           fputs("Memory error", stderr);
           fclose(file);
           return 2;
       }
   
       result = fread(buffer, 1, FILE_SIZE, file);
       if (result != FILE_SIZE) {
           fputs("Reading error", stderr);
           fclose(file);
           free(buffer);
           return 3;
       }
   
       fclose(file);
       free(buffer);
   
       return 0;
   }
   ```
   
   Result:
   
   ```shell
   #include <stdio.h>
   #include <stdlib.h>
   
   #define FILE_SIZE 64 * 1024 * 1024  // 64 MiB
   
   int main() {
       FILE *file;
       char *buffer;
       size_t result;
   
       file = fopen("/tmp/file", "rb");
       if (file == NULL) {
           fputs("Error opening file", stderr);
           return 1;
       }
   
       buffer = (char *)malloc(sizeof(char) * FILE_SIZE);
       if (buffer == NULL) {
           fputs("Memory error", stderr);
           fclose(file);
           return 2;
       }
   
       result = fread(buffer, 1, FILE_SIZE, file);
       if (result != FILE_SIZE) {
           fputs("Reading error", stderr);
           fclose(file);
           free(buffer);
           return 3;
       }
   
       fclose(file);
       free(buffer);
   
       return 0;
   }
   
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org