Commit 59369bed authored by Janez K's avatar Janez K

dodal benchmark output

parent 1a88039c
......@@ -446,6 +446,7 @@ class Widget(models.Model):
input_dict[i.variable]=[]
if not i.value==None:
input_dict[i.variable].append(i.value)
start = time.time()
try:
if not self.abstract_widget is None:
if self.abstract_widget.wsdl != '':
......@@ -469,9 +470,14 @@ class Widget(models.Model):
self.finished=False
self.save()
raise
elapsed = (time.time()-start)
outputs['clowdflows_elapsed']=elapsed
for o in self.outputs.all():
if not self.abstract_widget is None:
o.value = outputs[o.variable]
try:
o.value = outputs[o.variable]
except:
pass
o.save()
else:
#gremo v outpute pogledat
......
......@@ -675,10 +675,12 @@ function updateWidgetListeners() {
});
var widgetId = $(this).attr('id').replace("widgetconfiguration-","");
var benchmark = $("#benchmark-"+widgetId)[0].checked;
$.ajax({
url: url['save-configuration'],
type: "POST",
data: { 'widgetId':widgetId, 'inputs':inputs, 'params':params, 'outputs':outputs },
data: { 'widgetId':widgetId, 'inputs':inputs, 'params':params, 'outputs':outputs, 'benchmark':benchmark },
dataType: "json",
traditional: true,
success: function(data) {
......
......@@ -58,4 +58,11 @@
</div>
</div>
</div>
<div class="clear"><!----></div>
<div style="font-size: 3px;"><hr style="border:0px; height:1px; margin-top: 10px;margin-bottom: 10px; color:lightgray;background-color:lightgray;"/></div>
You can also measure the time needed to execute this widget and have the elapsed time be an output of the widget itself. Tick the checkbox and you're good to go:
<br><br>
<div>
<label><input style="float:left;width:15px;display:inline;" type="checkbox" id="benchmark-{{widget.pk}}" {% if benchmark_exists %}checked="checked"{% endif %}> Include an output that returns the elapsed execution time</label>
</div>
</div>
\ No newline at end of file
......@@ -673,7 +673,11 @@ def get_configuration(request):
inputs = w.inputs.filter(parameter=False);
parameters = w.inputs.filter(parameter=True);
outputs = w.outputs.all();
return render(request, 'configuration.html', {'widget':w,'inputs': inputs, 'parameters':parameters, 'outputs':outputs})
benchmark_exists = False
for o in outputs:
if o.variable=='clowdflows_elapsed':
benchmark_exists = True
return render(request, 'configuration.html', {'widget':w,'inputs': inputs, 'parameters':parameters, 'outputs':outputs, 'benchmark_exists':benchmark_exists})
else:
return HttpResponse(status=400)
else:
......@@ -729,6 +733,23 @@ def save_configuration(request):
out.order = id
reordered = True
out.save()
if request.POST.get('benchmark')=='true':
if widget.outputs.filter(variable='clowdflows_elapsed').count()==0:
new_o = Output()
new_o.widget = widget
new_o.variable = 'clowdflows_elapsed'
new_o.name = 'Elapsed time'
new_o.short_name = 'bmk'
new_o.order=99
new_o.save()
changed = True
reordered = True
if request.POST.get('benchmark')=='false':
o = widget.outputs.filter(variable='clowdflows_elapsed')
if len(o)>0:
o.delete()
changed = True
reordered = True
if (changed):
widget.unfinish()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment