Skip to content

Commit

Permalink
Added dump function
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Jun 14, 2024
1 parent 6d645ae commit 0f140fa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def set_silent():

parser.add_argument('--autoinput', action='store_true', help='Will get the CPU utilization through psutil.')
parser.add_argument('--interval', type=float, help='Interval in seconds if autoinput is used.', default=1.0)
parser.add_argument('--dump', action='store_true', help='Dump all predicitions to STDOUT.')
parser.add_argument('--dump-hashmap', action='store_true', help='Dump all predicitions to STDOUT as bash hashmap.')

args = parser.parse_args()

Expand Down Expand Up @@ -206,6 +208,20 @@ def cpu_utilization():
input_source = cpu_utilization()


if args.dump:
for key, val in interpolated_predictions.items():
print(key, ':', val*args.vhost_ratio, flush=True)
sys.exit(0)

if args.dump_hashmap:
print('#!/usr/bin/env bash')
print('set -eu')
print('declare -A cloud_energy_hashmap')
for key, val in interpolated_predictions.items():
print(f'cloud_energy_hashmap[{key:.2f}]={val*args.vhost_ratio}', flush=True)
sys.exit(0)


for line in input_source:
utilization = float(line.strip())
if utilization < 0 or utilization > 100:
Expand Down

0 comments on commit 0f140fa

Please sign in to comment.