| 383 | } |
| 384 | |
| 385 | void print_duration(double fmillis) { |
| 386 | if (fmillis < 1000.0f) { |
| 387 | printf("%.1fms", (float) fmillis); |
| 388 | return; |
| 389 | } |
| 390 | const int64_t one_sec = 1000; |
| 391 | const int64_t one_min = one_sec * 60; |
| 392 | const int64_t one_hour = one_min * 60; |
| 393 | const int64_t one_day = one_hour * 24; |
| 394 | |
| 395 | int64_t millis = (int64_t) fmillis; |
| 396 | int64_t days = millis/one_day; |
| 397 | int64_t hours = (millis - days*one_day)/one_hour; |
| 398 | int64_t minutes = (millis - days*one_day - hours*one_hour)/one_min; |
| 399 | int64_t seconds = (millis - days*one_day - hours*one_hour - minutes*one_min)/one_sec; |
| 400 | |
| 401 | // to print int64_t either cast to (long long int) or use macro PRId64 from <inttypes.h> |
| 402 | if (days > 0) { |
| 403 | printf("%lldd ", (long long int) days); |
| 404 | } |
| 405 | printf("%02lld:%02lld:%02lld", (long long int) hours, (long long int) minutes, (long long int) seconds); |
| 406 | } |
| 407 | |
| 408 | float cosine_decay(int64_t step, int64_t decay_steps, float minimum) { |
| 409 | if (step > decay_steps) { |
no test coverage detected