Hi,

I am working on a python plugin for QGIS where the user can interact with the 
data in a polygon memory layer.

When the user clicks on a position in the map, the plugin look up a feature at 
that position in the memory layer. If a feature was found it will be deleted 
and afterwards a new one will be created.

When the user repeat the click after the previous operation has finished the 
time it takes to perform the above delete/create part increases for each user 
click. Logging each step I found that the parts which takes longer are the 
layer.startEditing() and layer.commitChanges().

Below is the log information I collected and the relevant timings where created 
like this:

    log('Start editing.')
    layer.startEditing()
    log('Editing enabled.')

and

    log('Commit changes.')
    layer.commitChanges()
    log('Changes committed.')

so nothing happens before or after the two layer method calls in the above 
(just to clarify that it isn't some other python calls which takes up the time).

In the timings below notice that in the beginning no measurable time was used 
to enable and commit, but slowly it increases to seconds and then minutes (the 
memory layer is empty at first and then one item is added as seen in the log 
below):

2016-10-13 10:28:09 -> Start editing.
2016-10-13 10:28:09 -> Editing enabled.
2016-10-13 10:28:09 -> Look for existing feature.
2016-10-13 10:28:09 -> Add new feature.
2016-10-13 10:28:09 -> Commit changes.
2016-10-13 10:28:09 -> Changes committed.
2016-10-13 10:28:09 -> Start editing.
2016-10-13 10:28:09 -> Editing enabled.
2016-10-13 10:28:09 -> Look for existing feature.
2016-10-13 10:28:09 -> Found existing feature.
2016-10-13 10:28:09 -> Delete existing feature.
2016-10-13 10:28:09 -> Add new feature.
2016-10-13 10:28:09 -> Commit changes.
2016-10-13 10:28:09 -> Changes committed.

2016-10-13 10:28:11 -> Start editing.
2016-10-13 10:28:11 -> Editing enabled.
2016-10-13 10:28:11 -> Look for existing feature.
2016-10-13 10:28:11 -> Found existing feature.
2016-10-13 10:28:11 -> Delete existing feature.
2016-10-13 10:28:11 -> Add new feature.
2016-10-13 10:28:11 -> Commit changes.
2016-10-13 10:28:11 -> Changes committed.
2016-10-13 10:28:11 -> Start editing.
2016-10-13 10:28:11 -> Editing enabled.
2016-10-13 10:28:11 -> Look for existing feature.
2016-10-13 10:28:11 -> Found existing feature.
2016-10-13 10:28:11 -> Delete existing feature.
2016-10-13 10:28:11 -> Add new feature.
2016-10-13 10:28:11 -> Commit changes.
2016-10-13 10:28:11 -> Changes committed.

2016-10-13 10:28:14 -> Start editing.
2016-10-13 10:28:14 -> Editing enabled.
2016-10-13 10:28:14 -> Look for existing feature.
2016-10-13 10:28:14 -> Found existing feature.
2016-10-13 10:28:14 -> Delete existing feature.
2016-10-13 10:28:14 -> Add new feature.
2016-10-13 10:28:14 -> Commit changes.
2016-10-13 10:28:14 -> Changes committed.
2016-10-13 10:28:14 -> Start editing.
2016-10-13 10:28:14 -> Editing enabled.
2016-10-13 10:28:14 -> Look for existing feature.
2016-10-13 10:28:14 -> Found existing feature.
2016-10-13 10:28:14 -> Delete existing feature.
2016-10-13 10:28:14 -> Add new feature.
2016-10-13 10:28:14 -> Commit changes.
2016-10-13 10:28:14 -> Changes committed.

2016-10-13 10:28:16 -> Start editing.
2016-10-13 10:28:16 -> Editing enabled.
2016-10-13 10:28:16 -> Look for existing feature.
2016-10-13 10:28:16 -> Found existing feature.
2016-10-13 10:28:16 -> Delete existing feature.
2016-10-13 10:28:16 -> Add new feature.
2016-10-13 10:28:16 -> Commit changes.
2016-10-13 10:28:16 -> Changes committed.
2016-10-13 10:28:16 -> Start editing.
2016-10-13 10:28:16 -> Editing enabled.
2016-10-13 10:28:16 -> Look for existing feature.
2016-10-13 10:28:16 -> Found existing feature.
2016-10-13 10:28:16 -> Delete existing feature.
2016-10-13 10:28:16 -> Add new feature.
2016-10-13 10:28:16 -> Commit changes.
2016-10-13 10:28:16 -> Changes committed.

2016-10-13 10:28:18 -> Start editing.
2016-10-13 10:28:18 -> Editing enabled.
2016-10-13 10:28:18 -> Look for existing feature.
2016-10-13 10:28:18 -> Found existing feature.
2016-10-13 10:28:18 -> Delete existing feature.
2016-10-13 10:28:18 -> Add new feature.
2016-10-13 10:28:18 -> Commit changes.
2016-10-13 10:28:18 -> Changes committed.
2016-10-13 10:28:18 -> Start editing.
2016-10-13 10:28:18 -> Editing enabled.
2016-10-13 10:28:18 -> Look for existing feature.
2016-10-13 10:28:18 -> Found existing feature.
2016-10-13 10:28:18 -> Delete existing feature.
2016-10-13 10:28:18 -> Add new feature.
2016-10-13 10:28:18 -> Commit changes.
2016-10-13 10:28:18 -> Changes committed.

2016-10-13 10:28:19 -> Start editing.
2016-10-13 10:28:20 -> Editing enabled.
2016-10-13 10:28:20 -> Look for existing feature.
2016-10-13 10:28:20 -> Found existing feature.
2016-10-13 10:28:20 -> Delete existing feature.
2016-10-13 10:28:20 -> Add new feature.
2016-10-13 10:28:20 -> Commit changes.
2016-10-13 10:28:20 -> Changes committed.
2016-10-13 10:28:20 -> Start editing.
2016-10-13 10:28:22 -> Editing enabled.
2016-10-13 10:28:22 -> Look for existing feature.
2016-10-13 10:28:22 -> Found existing feature.
2016-10-13 10:28:22 -> Delete existing feature.
2016-10-13 10:28:22 -> Add new feature.
2016-10-13 10:28:22 -> Commit changes.
2016-10-13 10:28:26 -> Changes committed.

2016-10-13 10:28:32 -> Start editing.
2016-10-13 10:28:45 -> Editing enabled.
2016-10-13 10:28:45 -> Look for existing feature.
2016-10-13 10:28:45 -> Found existing feature.
2016-10-13 10:28:45 -> Delete existing feature.
2016-10-13 10:28:45 -> Add new feature.
2016-10-13 10:28:45 -> Commit changes.
2016-10-13 10:29:36 -> Changes committed.
2016-10-13 10:29:36 -> Start editing.
2016-10-13 10:32:03 -> Editing enabled.
2016-10-13 10:32:03 -> Look for existing feature.
2016-10-13 10:32:03 -> Found existing feature.
2016-10-13 10:32:03 -> Delete existing feature.
2016-10-13 10:32:03 -> Add new feature.
2016-10-13 10:32:03 -> Commit changes.
2016-10-13 10:38:18 -> Changes committed.

This was done on the latest Windows 7 x64 nightly build from OSGeo4W, while the 
same plugin on Ubuntu 16.04 x64 doesn't show this increase in time consumption.

Can anyone give me a clue to what might be happening here?


Regards, Casper
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to