for (int i = 0; i < nprops; i++) { // Make sure the name has at least 10 characters to make // it very unlikely to generate the same random name.
name_lens[i] = (random() % (PROP_NAME_MAX - 10)) + 10;
names[i] = newchar[PROP_NAME_MAX + 1];
size_t prop_name_len = sizeof(prop_name_chars) - 1; for (int j = 0; j < name_lens[i]; j++) { if (j == 0 || names[i][j-1] == '.' || j == name_lens[i] - 1) { // Certain values are not allowed: // - Don't start name with '.' // - Don't allow '.' to appear twice in a row // - Don't allow the name to end with '.' // This assumes that '.' is the last character in the // array so that decrementing the length by one removes // the value from the possible values.
prop_name_len--;
}
names[i][j] = prop_name_chars[random() % prop_name_len];
}
names[i][name_lens[i]] = 0;
// Make sure the value contains at least 1 character.
value_lens[i] = (random() % (PROP_VALUE_MAX - 1)) + 1;
values[i] = newchar[PROP_VALUE_MAX]; for (int j = 0; j < value_lens[i]; j++) {
values[i][j] = prop_name_chars[random() % (sizeof(prop_name_chars) - 1)];
}
if (system_properties_.Add(names[i], name_lens[i], values[i], value_lens[i]) < 0) {
printf("Failed to add a property, terminating...\n");
printf("%s = %.*s\n", names[i], value_lens[i], values[i]); exit(1);
}
}
// This benchmarks find the actual properties currently set on the system and accessible by the // user that runs this benchmark (aka this is best run as root). It is not comparable between // devices, nor even boots, but is useful to understand the the real end-to-end speed, including // costs to find the correct property file within /dev/__properties__. staticvoid BM_property_find_real(benchmark::State& state) {
std::vector<std::string> properties;
__system_property_foreach(
[](const prop_info* pi, void* cookie) {
__system_property_read_callback(pi,
[](void* cookie, constchar* name, constchar*, unsigned) { auto properties = reinterpret_cast<std::vector<std::string>*>(cookie);
properties->emplace_back(name);
},
cookie);
},
&properties);
while (state.KeepRunning()) { for (constauto& property : properties) {
__system_property_find(property.c_str());
}
}
}
BIONIC_BENCHMARK(BM_property_find_real);
#endif// __BIONIC__
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.