mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
test/perf: optimize the getdents test
* Use mknod instead of open&close to create an empty file. * Limit a number of files to (1<<16) instead of 100K. In this case, a test set is (1, 8, 64, 512, 4K, 32K, 64K) instead of (1, 8, 64, 512, 4K, 32K, 98K). I think it is easier to compare results for 32K and 64K than 32K and 98K. And results for 98K doesn't give us more information than for 54K. PiperOrigin-RevId: 275552507
This commit is contained in:
@@ -163,6 +163,26 @@ PosixError Chmod(absl::string_view path, int mode) {
|
||||
return NoError();
|
||||
}
|
||||
|
||||
PosixError MknodAt(const FileDescriptor& dfd, absl::string_view path, int mode,
|
||||
dev_t dev) {
|
||||
int res = mknodat(dfd.get(), std::string(path).c_str(), mode, dev);
|
||||
if (res < 0) {
|
||||
return PosixError(errno, absl::StrCat("mknod ", path));
|
||||
}
|
||||
|
||||
return NoError();
|
||||
}
|
||||
|
||||
PosixError UnlinkAt(const FileDescriptor& dfd, absl::string_view path,
|
||||
int flags) {
|
||||
int res = unlinkat(dfd.get(), std::string(path).c_str(), flags);
|
||||
if (res < 0) {
|
||||
return PosixError(errno, absl::StrCat("unlink ", path));
|
||||
}
|
||||
|
||||
return NoError();
|
||||
}
|
||||
|
||||
PosixError Mkdir(absl::string_view path, int mode) {
|
||||
int res = mkdir(std::string(path).c_str(), mode);
|
||||
if (res < 0) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "test/util/file_descriptor.h"
|
||||
#include "test/util/posix_error.h"
|
||||
|
||||
namespace gvisor {
|
||||
@@ -44,6 +45,14 @@ PosixError Delete(absl::string_view path);
|
||||
// Changes the mode of a file or returns an error.
|
||||
PosixError Chmod(absl::string_view path, int mode);
|
||||
|
||||
// Create a special or ordinary file.
|
||||
PosixError MknodAt(const FileDescriptor& dfd, absl::string_view path, int mode,
|
||||
dev_t dev);
|
||||
|
||||
// Unlink the file.
|
||||
PosixError UnlinkAt(const FileDescriptor& dfd, absl::string_view path,
|
||||
int flags);
|
||||
|
||||
// Truncates a file to the given length or returns an error.
|
||||
PosixError Truncate(absl::string_view path, int length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user