Commit af5ff742 authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

timing in a table for logging and debuging

parent e3754e32
BEGIN;
DROP TABLE IF EXISTS rv_update_timing;
CREATE TABLE rv_update_timing
(
update_id SERIAL CONSTRAINT pk_rv_update_timing PRIMARY KEY,
n_ways INTEGER,
n_nodes INTEGER,
update_begin TIMESTAMP,
update_end TIMESTAMP,
update_times FLOAT[]
);
COMMIT;
DROP FUNCTION IF EXISTS rv_timing_init();
CREATE FUNCTION rv_timing_init() RETURNS integer AS $$
BEGIN
RETURN 0::integer;
END;
$$ LANGUAGE plpgsql;
DROP FUNCTION IF EXISTS rv_timing(integer);
CREATE FUNCTION rv_timing(id integer) RETURNS VOID AS $$
BEGIN
END;
$$ LANGUAGE plpgsql;
DROP FUNCTION IF EXISTS rv_timing_init();
CREATE FUNCTION rv_timing_init() RETURNS integer AS $$
DECLARE
id integer;
n_w integer;
n_n integer;
t timestamp;
BEGIN
SELECT count(*) FROM actions WHERE data_type='N' INTO n_n;
SELECT count(*) FROM actions WHERE data_type='W' INTO n_w;
SELECT timeofday()::TIMESTAMP INTO t;
INSERT INTO rv_update_timing
(n_ways,n_nodes,update_begin,update_end)
VALUES
(n_w,n_n,t,t)
RETURNING update_id INTO id;
RETURN id;
END;
$$ LANGUAGE plpgsql;
DROP FUNCTION IF EXISTS rv_timing(integer);
CREATE FUNCTION rv_timing(id integer) RETURNS VOID AS $$
DECLARE
t1 timestamp;
t2 timestamp;
k integer;
dt float;
BEGIN
SELECT
*
FROM
(
(
SELECT
1::integer
FROM
rv_update_timing
WHERE
array_length(update_times,1) IS NULL
AND update_id=id
)
UNION
(
SELECT
1+array_length(update_times,1)
FROM
rv_update_timing
WHERE
NOT array_length(update_times,1) IS NULL
AND
update_id=id
)
) AS sub
INTO k;
SELECT update_end FROM rv_update_timing WHERE update_id=id INTO t1;
SELECT timeofday()::TIMESTAMP INTO t2;
SELECT date_part('epoch',(t2-t1)) INTO dt;
UPDATE rv_update_timing SET update_end=t2 WHERE update_id=id;
UPDATE rv_update_timing SET update_times[k]=dt WHERE update_id=id;
RAISE NOTICE 'rv_timing: step %: % seconds', k, dt;
END;
$$ LANGUAGE plpgsql;
......@@ -4,11 +4,10 @@
DROP FUNCTION IF EXISTS updateRV();
CREATE FUNCTION updateRV() RETURNS VOID AS $$
DECLARE
v TIMESTAMP;
update_id integer;
BEGIN
select timeofday() into v;
raise notice '% Begin of DELETE rv_ways', v;
SELECT rv_timinig_init() INTO update_id;
-- update de rv_way
-- etape 1 : effacement des ways effacée ou modifiée
......@@ -27,8 +26,7 @@ BEGIN
WHERE
rv_ways.id=sub.id;
select timeofday() into v;
raise notice '% Begin of INSERT rv_ways', v;
PERFORM rv_timing(update_id); -- 1
-- etape 2 : on crée les ways nouvelles et les modifiés (qui viennet d'être
-- effacées
INSERT INTO rv_ways
......@@ -53,8 +51,7 @@ BEGIN
)
);
select timeofday() into v;
raise notice '% Begin of DELETE rv_edges', v;
PERFORM rv_timing(update_id); -- 2
-- rv_edges
-- etape 1 : on effacte tous les edges qui proviennent d'un ways
DELETE FROM rv_edges
......@@ -72,8 +69,8 @@ BEGIN
WHERE
way_id=sub.id;
select timeofday() into v;
raise notice '% Begin of computing rv_edges', v;
PERFORM rv_timing(update_id); -- 3
-- etape 2 : on crée tous les edges des ways crées ou modifés
PERFORM compute_edges_for_one_way(sub.id)
FROM
......@@ -90,8 +87,8 @@ BEGIN
(action='C' OR action='M')
) AS sub;
select timeofday() into v;
raise notice '% Begin of INSERT actions', v;
PERFORM rv_timing(update_id); -- 4
-- rv_nodes
-- etape 1: on considère que tous les nodes apparenants à des ways modifiés
-- ont été potentiellement modifés (la ways peut avoir été marqué comme
......@@ -127,8 +124,8 @@ BEGIN
);
select timeofday() into v;
raise notice '% Begin of DELETE rv_nodes', v;
PERFORM rv_timing(update_id); -- 5
-- etape 2 : on effacte tous les nœuds supprimés ou modifés
DELETE FROM rv_nodes
USING
......@@ -144,8 +141,8 @@ BEGIN
rv_nodes.id=sub.node_id;
select timeofday() into v;
raise notice '% Begin of INSERT rv_nodes', v;
PERFORM rv_timing(update_id); -- 6
-- etape 3 : on insere (ou re-insere) tous les noeuds crées (ou modifiés)
INSERT INTO rv_nodes
(
......@@ -177,8 +174,8 @@ BEGIN
-- puis on mets à jour les labels de cc à partir de ceux calculés sur
-- le graph dual
select timeofday() into v;
raise notice '% Begin of creating rv_way_way', v;
PERFORM rv_timing(update_id); -- 7
CREATE TEMP TABLE rv_way_way (id1 BIGINT, id2 BIGINT);
INSERT INTO rv_way_way
(
......@@ -203,8 +200,8 @@ BEGIN
rv_ways AS w
);
select timeofday() into v;
raise notice '% Begin of creating rv_way_cc', v;
PERFORM rv_timing(update_id); -- 8
CREATE TEMP TABLE rv_way_cc (way_id BIGINT, cc_id BIGINT);
INSERT INTO rv_way_cc
(
......@@ -215,12 +212,12 @@ BEGIN
rv_ways AS w
);
select timeofday() into v;
raise notice '% Begin of propto', v;
PERFORM rv_timing(update_id); -- 9
PERFORM propto();
select timeofday() into v;
raise notice '% Begin of UPDATE rv_nodes for CC', v;
PERFORM rv_timing(update_id); -- 10
UPDATE rv_nodes
SET
cc=sub.cc
......@@ -240,9 +237,7 @@ BEGIN
sub.id=rv_nodes.id;
select timeofday() into v;
raise notice '% End of updateRV', v;
PERFORM rv_timing(update_id); -- 11
END;
$$ LANGUAGE plpgsql;
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