MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / pflash_keep_ratio

Function pflash_keep_ratio

server/src/server/http_server.cpp:113–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113// ─── piecewise keep-ratio curve ─────────────────────────────────────────
114
115static float pflash_keep_ratio(const ServerConfig & cfg, int n_tokens) {
116 if (cfg.pflash_curve.empty()) return cfg.pflash_keep_ratio;
117 const auto & curve = cfg.pflash_curve;
118 if (n_tokens <= curve.front().first) return curve.front().second;
119 if (n_tokens >= curve.back().first) return curve.back().second;
120 for (size_t i = 0; i + 1 < curve.size(); ++i) {
121 if (n_tokens <= curve[i + 1].first) {
122 float t = (float)(n_tokens - curve[i].first) /
123 (float)(curve[i + 1].first - curve[i].first);
124 return curve[i].second + t * (curve[i + 1].second - curve[i].second);
125 }
126 }
127 return curve.back().second;
128}
129

Callers 1

worker_loopMethod · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected