From pressy's brainbackup
Jump to: navigation, search

CPU Load DB Burner

Just a small script to burn one of your cpus, perhaps to see a different on single thread performance or some other things like CPU time vs. execution time (should be the same)...

create or replace procedure Burn_CPU_For_pressy authid Definer is
  Loops constant pls_integer := 10 * 100 * 1000 * 1000;
  w0 constant integer not null := DBMS_Utility.Get_Time();
  c0 constant integer not null := DBMS_Utility.Get_CPU_Time();
  c integer not null := 0;
  w integer not null := 0;
  k integer not null := 0;
  for j in 1..Loops loop
    k := k + 1.5;
  end loop;
  c := DBMS_Utility.Get_CPU_Time() - c0;
  w := DBMS_Utility.Get_Time() - w0;
    'CPU:  '||To_Char(c/100.0, '999.9')||' '||
    'Wall: '||To_Char(w/100.0, '999.9')||' '||
    'k: '||k);
end Burn_CPU_For_pressy;
set serveroutput on
execute Burn_CPU_For_pressy;
drop procedure Burn_CPU_For_pressy;