From ae4e65296cde45f85683787ddb4e3901975857c6 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 18:04:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 14 +++----------- db/migrate/20190718100242_add_ts_mem_to_outputs.rb | 5 +++++ 2 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20190718100242_add_ts_mem_to_outputs.rb diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 7ced33156..0a19f1c08 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -104,15 +104,6 @@ class MyshixunsController < ApplicationController logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) - # 资源消耗 - if jsonTestDetails['resUsage'].present? - max_mem = tran_base64_decode64(jsonTestDetails['resUsage']).to_f - uid_logger("6661111111111111122222#{max_mem}") - max_mem = format("%.3f", max_mem/1024/1024).to_f - uid_logger("444411111122222#{max_mem}") - end - - uid_logger("1111111111111122222#{max_mem}") jenkins_testsets = jsonTestDetails['msg'] compile_success = jsonTestDetails['compileSuccess'] @@ -139,10 +130,11 @@ class MyshixunsController < ApplicationController # is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public) logger.info "actual_output:################################################# #{actual_output}" ts_time = format("%.2f", j_test_set['testSetTime'].to_f/1000000000).to_f + ts_mem = format("%.2f", j_test_set['testSetMem'].to_f/1024/1024).to_f Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index, - :compile_success => compile_success.to_i, :sec_key => sec_key, :ts_time => ts_time) + :compile_success => compile_success.to_i, :sec_key => sec_key, :ts_time => ts_time, :ts_mem => ts_mem) # 如果设置了按测试集给分,则需要统计测试集的分值 if challenge.test_set_score && j_test_set['passed'].to_i == 1 test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first @@ -212,7 +204,7 @@ class MyshixunsController < ApplicationController consume_time = format("%.3f", (Time.now - record.created_at)).to_f record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], - :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :max_mem => max_mem, + :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end uid_logger("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") diff --git a/db/migrate/20190718100242_add_ts_mem_to_outputs.rb b/db/migrate/20190718100242_add_ts_mem_to_outputs.rb new file mode 100644 index 000000000..70b593a35 --- /dev/null +++ b/db/migrate/20190718100242_add_ts_mem_to_outputs.rb @@ -0,0 +1,5 @@ +class AddTsMemToOutputs < ActiveRecord::Migration[5.2] + def change + add_column :outputs, :ts_mem, :float + end +end