Example #1
0
double surf_parse_get_bandwidth(const char* string, const char* entity_kind, std::string name)
{
  static const unit_scale units{std::make_tuple("bps", 0.125, 2, true), std::make_tuple("bps", 0.125, 10, true),
                                std::make_tuple("Bps", 1.0, 2, true), std::make_tuple("Bps", 1.0, 10, true)};
  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
      "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
}
Example #2
0
double surf_parse_get_size(const char* string, const char* entity_kind, std::string name)
{
  static const unit_scale units{std::make_tuple("b", 0.125, 2, true), std::make_tuple("b", 0.125, 10, true),
                                std::make_tuple("B", 1.0, 2, true), std::make_tuple("B", 1.0, 10, true)};
  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
      "Append 'B' to get bytes (or 'b' for bits but 1B = 8b).", "B");
}
Example #3
0
double surf_parse_get_time(const char* string, const char* entity_kind, std::string name)
{
  static const unit_scale units{std::make_pair("w", 7 * 24 * 60 * 60),
                                std::make_pair("d", 24 * 60 * 60),
                                std::make_pair("h", 60 * 60),
                                std::make_pair("m", 60),
                                std::make_pair("s", 1.0),
                                std::make_pair("ms", 1e-3),
                                std::make_pair("us", 1e-6),
                                std::make_pair("ns", 1e-9),
                                std::make_pair("ps", 1e-12)};
  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
      "Append 's' to your time to get seconds", "s");
}
double surf_parse_get_time(const char *string, const char *entity_kind, const char *name)
{
  const struct unit_scale units[] = {
    { "w",  7 * 24 * 60 * 60 },
    { "d",  24 * 60 * 60 },
    { "h",  60 * 60 },
    { "m",  60 },
    { "s",  1.0 },
    { "ms", 1e-3 },
    { "us", 1e-6 },
    { "ns", 1e-9 },
    { "ps", 1e-12 },
    { nullptr, 0 }
  };
  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
      "Append 's' to your time to get seconds", "s");
}
Example #5
0
double surf_parse_get_time(const char *string)
{
  const struct unit_scale units[] = {
    { "w",  7 * 24 * 60 * 60 },
    { "d",  24 * 60 * 60 },
    { "h",  60 * 60 },
    { "m",  60 },
    { "s",  1.0 },
    { "",   1.0 },              /* default unit is seconds */
    { "ms", 1e-3 },
    { "us", 1e-6 },
    { "ns", 1e-9 },
    { "ps", 1e-12 },
    { NULL, 0 }
  };
  return surf_parse_get_value_with_unit(string, units);
}
Example #6
0
double surf_parse_get_speed(const char* string, const char* entity_kind, std::string name)
{
  static const unit_scale units{std::make_tuple("f", 1.0, 10, true), std::make_tuple("flops", 1.0, 10, false)};
  return surf_parse_get_value_with_unit(string, units, entity_kind, name,
      "Append 'f' or 'flops' to your speed to get flop per second", "f");
}