| 1 | % (c) 2016-2019 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | :- module(performance_messages, | |
| 6 | [ | |
| 7 | performance_monitoring_on/0, | |
| 8 | perfmessage/1, perfmessage/2, | |
| 9 | perfmessagecall/2, perfmessagecall/3, | |
| 10 | toggle_perfmessages/0 | |
| 11 | ]). | |
| 12 | ||
| 13 | :- use_module(preferences). | |
| 14 | :- use_module(error_manager). | |
| 15 | ||
| 16 | % ------------------------------------------- | |
| 17 | ||
| 18 | :- dynamic performance_monitoring_on/0. % should we use a preference | |
| 19 | %performance_monitoring_on. | |
| 20 | ||
| 21 | performance_monitoring_on :- get_preference(performance_monitoring_on,true). | |
| 22 | ||
| 23 | toggle_perfmessages :- print('TURNING PERF-MESSAGES '), | |
| 24 | (performance_monitoring_on | |
| 25 | -> set_preference(performance_monitoring_on,false), print('OFF') | |
| 26 | ; set_preference(performance_monitoring_on,true), print('ON')),nl. | |
| 27 | ||
| 28 | perfmessage(M) :- preference(performance_monitoring_on,true),!, | |
| 29 | format(user_output,'==PERF-MESSAGE==> ~w~n',[M]). | |
| 30 | perfmessage(_). | |
| 31 | ||
| 32 | perfmessage(M,Location) :- preference(performance_monitoring_on,true),!, | |
| 33 | add_warning(performance_message,'==PERF-MESSAGE==> ',M,Location). | |
| 34 | perfmessage(_,_). | |
| 35 | ||
| 36 | :- meta_predicate perfmessagecall(*,0). | |
| 37 | perfmessagecall(M,Call) :- preference(performance_monitoring_on,true),!, | |
| 38 | format(user_output,'==PERF-MESSAGE==> ~w : ',[M]), | |
| 39 | call(Call),nl(user_output). | |
| 40 | perfmessagecall(_,_). | |
| 41 | ||
| 42 | :- meta_predicate perfmessagecall(*,0,*). | |
| 43 | perfmessagecall(M,Call,Location) :- preference(performance_monitoring_on,true),!, | |
| 44 | call(Call),nl(user_output), | |
| 45 | add_warning(performance_message,'==PERF-MESSAGE==> ',M,Location). | |
| 46 | perfmessagecall(_,_,_). |