Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 1214)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 1215)
@@ -767,4 +767,14 @@
     // Shows areas before non-areas
     public void visitAll(DataSet data, Boolean virtual) {
+	
+		boolean profiler = Main.pref.getBoolean("mappaint.profiler",false);
+		long profilerStart = java.lang.System.currentTimeMillis();
+		long profilerLast = profilerStart;
+		int profilerN;
+		if(profiler)
+		{
+			System.out.println("Mappaint Profiler");
+		}
+		
         getSettings(virtual);
         untaggedColor = Main.pref.getColor(marktr("untagged"),Color.GRAY);
@@ -785,13 +795,32 @@
         selectedCall = false;
 
+		if(profiler) 
+		{
+			System.out.format("Prepare  : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
+			profilerLast = java.lang.System.currentTimeMillis();
+		}
+		
         if (fillAreas && styles.hasAreas()) {
             Collection<Way> noAreaWays = new LinkedList<Way>();
 
+			/*** RELATIONS ***/
+			profilerN = 0;
             for (final Relation osm : data.relations)
             {
                 if(!osm.deleted && !osm.incomplete)
+				{
                     osm.visit(this);
-            }
-
+					profilerN++;
+				}
+            }
+
+			if(profiler) 
+			{
+				System.out.format("Relations: %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+				profilerLast = java.lang.System.currentTimeMillis();
+			}
+			
+			/*** AREAS ***/
+			profilerN = 0;
             for (final Way osm : data.ways)
             {
@@ -799,45 +828,119 @@
                 {
                     if(styles.isArea((Way)osm) && !alreadyDrawnAreas.contains(osm))
+                    {
                         osm.visit(this);
-                    else
+                        profilerN++;
+                    } else
                         noAreaWays.add((Way)osm);
                 }
             }
             alreadyDrawnAreas = null;
-
+			
+			if(profiler) 
+			{
+				System.out.format("Areas    : %4dms, n=%d\n",  (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+				profilerLast = java.lang.System.currentTimeMillis();
+			}
+
+			/*** WAYS ***/
+			profilerN = 0;
             fillAreas = false;
             for (final OsmPrimitive osm : noAreaWays)
+            {
                 osm.visit(this);
+                profilerN++;
+            }
+			
+			if(profiler) 
+			{
+				System.out.format("Ways     : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+				profilerLast = java.lang.System.currentTimeMillis();
+			}
         }
         else
         {
+			/*** WAYS (filling disabled)  ***/			
+			profilerN = 0;
             for (final OsmPrimitive osm : data.ways)
                 if (!osm.incomplete && !osm.deleted && !osm.selected)
+				{
                     osm.visit(this);
-        }
-
+                    profilerN++;
+				}
+					
+			if(profiler) 
+			{
+				System.out.format("Ways     : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+				profilerLast = java.lang.System.currentTimeMillis();
+			}
+        }
+
+		/*** SELECTED  ***/
         selectedCall = true;
+		profilerN = 0;
         for (final OsmPrimitive osm : data.getSelected()) {
             if (!osm.incomplete && !osm.deleted
             && !(osm instanceof Node) && !alreadyDrawn.contains(osm))
+			{
                 osm.visit(this);
-        }
-
+				profilerN++;
+			}
+        }
+		
+		if(profiler) 
+		{
+			System.out.format("Selected : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+			profilerLast = java.lang.System.currentTimeMillis();
+		}
+
+		/*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/
         displaySegments();
-
+		/*System.out.println("display segments " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms");
+		profilerLast = java.lang.System.currentTimeMillis();*/
+
+		/*** NODES ***/
+		profilerN = 0;
         for (final OsmPrimitive osm : data.nodes)
             if (!osm.incomplete && !osm.deleted && !alreadyDrawn.contains(osm))
+            {
                 osm.visit(this);
+				profilerN++;
+			}
+				
+		if(profiler) 
+		{
+			System.out.format("Nodes    : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+			profilerLast = java.lang.System.currentTimeMillis();
+		}
 
         alreadyDrawn = null;
 
+		/*** VIRTUAL  ***/
         if (virtualNodeSize != 0)
         {
+			profilerN = 0;
             currentColor = nodeColor;
             for (final OsmPrimitive osm : data.ways)
                 if (!osm.incomplete && !osm.deleted)
+				{
                     visitVirtual((Way)osm);
-            displaySegments(null);
-        }
+					profilerN++;
+				}
+					
+			if(profiler) 
+			{
+				System.out.format("Virtual  : %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
+				profilerLast = java.lang.System.currentTimeMillis();
+			}
+            
+			displaySegments(null);
+			/*System.out.println("display segments virtual " + (java.lang.System.currentTimeMillis()-profilerLast) + "ms");
+			profilerLast = java.lang.System.currentTimeMillis();*/
+        }
+		
+		if(profiler) 
+		{
+			System.out.format("All      : %4dms\n", (profilerLast-profilerStart));
+		}
     }
 
