WebKit Bugzilla
Attachment 341015 Details for
Bug 185882
: [POSIX] Use access() instead of stat() in FileSystem::fileExists()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Benchmark
statperf.cpp (text/x-csrc), 1.76 KB, created by
Chris Dumez
on 2018-05-22 13:52:09 PDT
(
hide
)
Description:
Benchmark
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-05-22 13:52:09 PDT
Size:
1.76 KB
patch
obsolete
>// clang++ -O3 -Wall -std=c++14 statperf.cpp -o statperf > >#include <unistd.h> >#include <mach/mach.h> >#include <mach/mach_time.h> >#include <mutex> >#include <sys/stat.h> > >double now() >{ > static mach_timebase_info_data_t timebaseInfo; > static std::once_flag initializeTimerOnceFlag; > std::call_once(initializeTimerOnceFlag, [] { > mach_timebase_info(&timebaseInfo); > }); > > return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom); >} > >int main(int argc, const char** argv) >{ > if (argc < 2) { > fprintf(stderr, "Usage: %s <file_path>\n", argv[0]); > return 1; > } > > const int runCount = 100000; > const char* path = argv[1]; > double begin = now(); > for (int i = 0; i < runCount; ++i) { > struct stat fileInfo; > if (stat(path, &fileInfo)) { > fprintf(stderr, "Oops, file did not exist a\n"); > return 1; > } > } > printf("stat: %g (lower is better)\n", now() - begin); > > begin = now(); > for (int i = 0; i < runCount; ++i) { > if (access(path, F_OK) == -1) { > fprintf(stderr, "Oops, file did not exist b\n"); > return 1; > } > } > printf("access: %g (lower is better)\n", now() - begin); > > begin = now(); > for (int i = 0; i < runCount; ++i) { > struct stat fileInfo; > if (stat(path, &fileInfo)) { > fprintf(stderr, "Oops, file did not exist a\n"); > return 1; > } > } > printf("stat: %g (lower is better)\n", now() - begin); > > begin = now(); > for (int i = 0; i < runCount; ++i) { > if (access(path, F_OK) == -1) { > fprintf(stderr, "Oops, file did not exist b\n"); > return 1; > } > } > printf("access: %g (lower is better)\n", now() - begin); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 185882
: 341015 |
341017
|
341020