473,507 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

slowness

I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs ( and
all by value entities ) are thread safe, which if its locking some mutex or
semiphore could account for the bog. Is this what the problem is or could it
be something else?

How can I speed up the process of getting the points out of the
graphicsPath?
heres a litte sample of my point class...just the construction

internal class Point2D
{
#region Member Variables
float m_X;
float m_Y;
#endregion

#region Constructor

public Point2D()
{
m_X = 0;
m_Y = 0;
}

public Point2D( float x, float y )
{
m_X = x;
m_Y = y;
}

public Point2D( Point2D pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

public Point2D( PointF pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

......
Nov 16 '05 #1
7 1888
Jason,

It doesn't look like you are using structures though. Also, if you are
creating 2000 instances of these objects, that's going to take some time
(not 10 seconds, but definitely some overhead).

Can you show some code indicating how you are using these class
instances? That would give a better idea.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason" <Ja***@mobiform.com> wrote in message
news:e%***************@TK2MSFTNGP09.phx.gbl...
I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations
on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs (
and
all by value entities ) are thread safe, which if its locking some mutex
or
semiphore could account for the bog. Is this what the problem is or could
it
be something else?

How can I speed up the process of getting the points out of the
graphicsPath?
heres a litte sample of my point class...just the construction

internal class Point2D
{
#region Member Variables
float m_X;
float m_Y;
#endregion

#region Constructor

public Point2D()
{
m_X = 0;
m_Y = 0;
}

public Point2D( float x, float y )
{
m_X = x;
m_Y = y;
}

public Point2D( Point2D pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

public Point2D( PointF pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

.....

Nov 16 '05 #2
Jason <Ja***@mobiform.com> wrote:
I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs ( and
all by value entities ) are thread safe, which if its locking some mutex or
semiphore could account for the bog. Is this what the problem is or could it
be something else?


There's nothing inherently thread-safe about structs. If you have a
struct as shared data (as a member of a shared reference type object,
for example, or in an array) you have exactly the same problems as you
would with reference types.

You haven't shown how you're actually getting the points out of the
path.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Heres a sample. Its going to make a number of polygons ( if there are is more than 1 path in the graphics path ) from the graphicss Path, each polygon is just a wrapper for a ArrayList of Point2Ds.
public static ArrayList CreateFromGraphicsPath( GraphicsPath graphicsPath )
{
ArrayList polygonList = new ArrayList();

bool bCloseSubPath = false;
bool bLine = false;
bool bBezier = false;

Polygon polygon = new Polygon();

for ( int i = 1; i < graphicsPath.PathPoints.Length; i++ )
{


GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i]) );
}

}

if ( bCloseSubPath )
{
polygonList.Add( polygon );
polygon = new Polygon();
}
}
return polygonList;
}

And the top bit of polygon that covers adding/getting points

internal class Polygon
{
ArrayList m_Points = new ArrayList();

int m_CachedIsSimple = -1;

public Polygon( )
{
}


public void AddPoint ( Point2D point )
{
m_Points.Add( point );
}

public Point2D GetPoint ( int index )
{
Debug.Assert ( index >= 0 );
Debug.Assert ( index < GetPointCount() );

return m_Points[index] as Point2D;
//return (Point2D) m_Points[index];
}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Jason,

It doesn't look like you are using structures though. Also, if you are
creating 2000 instances of these objects, that's going to take some time
(not 10 seconds, but definitely some overhead).

Can you show some code indicating how you are using these class
instances? That would give a better idea.


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason" <Ja***@mobiform.com> wrote in message
news:e%***************@TK2MSFTNGP09.phx.gbl...
I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations
on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs (
and
all by value entities ) are thread safe, which if its locking some mutex
or
semiphore could account for the bog. Is this what the problem is or could
it
be something else?

How can I speed up the process of getting the points out of the
graphicsPath?
heres a litte sample of my point class...just the construction

internal class Point2D
{
#region Member Variables
float m_X;
float m_Y;
#endregion

#region Constructor

public Point2D()
{
m_X = 0;
m_Y = 0;
}

public Point2D( float x, float y )
{
m_X = x;
m_Y = y;
}

public Point2D( Point2D pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

public Point2D( PointF pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

.....



Nov 16 '05 #4
actually I did... it should be showing up any time now ;)

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jason <Ja***@mobiform.com> wrote:
I have a graphicsPath object filled up with apporximately 2000 points, I am coping them out into my own point class so I can do some extra operations on them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to just getting the points out of the graphics path. I read that structs ( and all by value entities ) are thread safe, which if its locking some mutex or semiphore could account for the bog. Is this what the problem is or could it be something else?


There's nothing inherently thread-safe about structs. If you have a
struct as shared data (as a member of a shared reference type object,
for example, or in an array) you have exactly the same problems as you
would with reference types.

You haven't shown how you're actually getting the points out of the
path.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5
this might be helpful also

private static void GetGraphicsPathTypeInfo( byte pathType, ref bool bCloseSubPath, ref bool bLine, ref bool bBezier )

{

bCloseSubPath = ( pathType & (byte)PathPointType.CloseSubpath ) > 0;

if ( bCloseSubPath )

{//remove CloseSubpath flag since its OR'ed in

pathType = (byte)(pathType & (~(byte)PathPointType.CloseSubpath));

}

bLine = ( pathType == (byte)PathPointType.Line );

bBezier = ( pathType == (byte)PathPointType.Bezier );

// JW - bezier and bezier3 appear to be the same

// bool bBezier3 = ( pathType == (byte)PathPointType.Bezier3 );

}

"Jason" <Ja***@mobiform.com> wrote in message news:uY*************@TK2MSFTNGP10.phx.gbl...
Heres a sample. Its going to make a number of polygons ( if there are is more than 1 path in the graphics path ) from the graphicss Path, each polygon is just a wrapper for a ArrayList of Point2Ds.
public static ArrayList CreateFromGraphicsPath( GraphicsPath graphicsPath )
{
ArrayList polygonList = new ArrayList();

bool bCloseSubPath = false;
bool bLine = false;
bool bBezier = false;

Polygon polygon = new Polygon();

for ( int i = 1; i < graphicsPath.PathPoints.Length; i++ )
{


GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i]) );
}

}

if ( bCloseSubPath )
{
polygonList.Add( polygon );
polygon = new Polygon();
}
}
return polygonList;
}

And the top bit of polygon that covers adding/getting points

internal class Polygon
{
ArrayList m_Points = new ArrayList();

int m_CachedIsSimple = -1;

public Polygon( )
{
}
public void AddPoint ( Point2D point )
{
m_Points.Add( point );
}

public Point2D GetPoint ( int index )
{
Debug.Assert ( index >= 0 );
Debug.Assert ( index < GetPointCount() );

return m_Points[index] as Point2D;
//return (Point2D) m_Points[index];
}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Jason,

It doesn't look like you are using structures though. Also, if you are
creating 2000 instances of these objects, that's going to take some time
(not 10 seconds, but definitely some overhead).

Can you show some code indicating how you are using these class
instances? That would give a better idea.


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason" <Ja***@mobiform.com> wrote in message
news:e%***************@TK2MSFTNGP09.phx.gbl...
I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations
on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs (
and
all by value entities ) are thread safe, which if its locking some mutex
or
semiphore could account for the bog. Is this what the problem is or could
it
be something else?

How can I speed up the process of getting the points out of the
graphicsPath?
heres a litte sample of my point class...just the construction

internal class Point2D
{
#region Member Variables
float m_X;
float m_Y;
#endregion

#region Constructor

public Point2D()
{
m_X = 0;
m_Y = 0;
}

public Point2D( float x, float y )
{
m_X = x;
m_Y = y;
}

public Point2D( Point2D pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

public Point2D( PointF pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

.....



Nov 16 '05 #6
Jason <Ja***@mobiform.com> wrote:
actually I did... it should be showing up any time now ;)


No you didn't.

See http://www.pobox.com/~skeet/csharp/incomplete.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
Jason,

Is your C++ code using the GDI+ library as well? Maybe you should post that
too so we can compare them.

Another test you could try is comparing regular C++ to managed C++. If that
causes a slowdown, you know the problem is the "managed-ness" and not the
specific language choice.

-- Matt

"Jason" wrote:
Heres a sample. Its going to make a number of polygons ( if there are is more than 1 path in the graphics path ) from the graphicss Path, each polygon is just a wrapper for a ArrayList of Point2Ds.
public static ArrayList CreateFromGraphicsPath( GraphicsPath graphicsPath )
{
ArrayList polygonList = new ArrayList();

bool bCloseSubPath = false;
bool bLine = false;
bool bBezier = false;

Polygon polygon = new Polygon();

for ( int i = 1; i < graphicsPath.PathPoints.Length; i++ )
{
GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPathTypeInfo( (byte)graphicsPath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoint( new Point2D(graphicsPath.PathPoints[i]) );
}

}

if ( bCloseSubPath )
{
polygonList.Add( polygon );
polygon = new Polygon();
}
}
return polygonList;
}

And the top bit of polygon that covers adding/getting points

internal class Polygon
{
ArrayList m_Points = new ArrayList();

int m_CachedIsSimple = -1;

public Polygon( )
{
}
public void AddPoint ( Point2D point )
{
m_Points.Add( point );
}

public Point2D GetPoint ( int index )
{
Debug.Assert ( index >= 0 );
Debug.Assert ( index < GetPointCount() );

return m_Points[index] as Point2D;
//return (Point2D) m_Points[index];
}
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Jason,

It doesn't look like you are using structures though. Also, if you are
creating 2000 instances of these objects, that's going to take some time
(not 10 seconds, but definitely some overhead).

Can you show some code indicating how you are using these class
instances? That would give a better idea.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason" <Ja***@mobiform.com> wrote in message
news:e%***************@TK2MSFTNGP09.phx.gbl...
I have a graphicsPath object filled up with apporximately 2000 points, I am
coping them out into my own point class so I can do some extra operations
on
them, its super slow. In C++ this would be pretty fast, not instant, but
would take in the milliseconds, in c# is taking up to 10 seconds. The
operations I am doing are really complicated but blazing fast compared to
just getting the points out of the graphics path. I read that structs (
and
all by value entities ) are thread safe, which if its locking some mutex
or
semiphore could account for the bog. Is this what the problem is or could
it
be something else?

How can I speed up the process of getting the points out of the
graphicsPath?
heres a litte sample of my point class...just the construction

internal class Point2D
{
#region Member Variables
float m_X;
float m_Y;
#endregion

#region Constructor

public Point2D()
{
m_X = 0;
m_Y = 0;
}

public Point2D( float x, float y )
{
m_X = x;
m_Y = y;
}

public Point2D( Point2D pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

public Point2D( PointF pointToCopy )
{
m_X = pointToCopy.X;
m_Y = pointToCopy.Y;
}

.....


Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1429
by: _BNC | last post by:
I've got an ArrayList of objects that I'd like to save/retrieve as quickly as possible. Each item in the arraylist is an object with about 50 variable-length strings; many zero-length, some about...
6
2989
by: Jason K | last post by:
Let me preface this by saying this obviously isn't a C++ *language* issue per se; rather probably an issue relating to quality of implementation, unless I'm just misusing iostream... I wrote a...
10
3186
by: David | last post by:
Hi everyone, Hoping there are some .js/browser experts out there that can help with this weird problem. I have made a swap div routine and applied the events to menu buttons with a closer...
0
1116
by: Nicole | last post by:
Has anyone else experienced a dramatic slow down of performance with their ADP's after upgrading to Service Pack 2 or above? The slowness occurs exclusively when pulling data from SQL Server in...
0
1088
by: Newbillian | last post by:
I am using Access 2003 and each time I select an object with the mouse in the report design view, the system hangs for about 5 seconds before I can move on to another one. It really slows down...
7
2151
by: Mike Nygard | last post by:
I'm experiencing extremely slow response times in design mode of my forms since moving to Access 2003. Simply dragging a button to a different position on the form takes 30 seconds or more. The...
0
822
by: Art | last post by:
Hi, I'm working on an application that writes records to an Access database. What I've got so far works, but very slowly. I have one class that creates the data -- some of it is as follows...
2
1167
by: BerkshireGuy | last post by:
I am using Windows 2000 and Access 2003 and noticed that when I click a control on a report, it takes a few seconds for the "click" to take place. Its laggy. Same with moving controls, adding new...
9
1154
by: allenjo5 | last post by:
Here's a code snippet: i = 0 while (i < 20): i = i + 1 (shellIn, shellOut) = os.popen4("/bin/sh -c ':'") # for testing, the spawned shell does nothing print 'next' # for line in shellOut:...
0
983
by: =?Utf-8?B?SmFjY2k=?= | last post by:
Hello, I'm having trouble creating a new folder. Right clicking or going to File, New, the arrow turns into an hourglass and for at least a minute, then I can create a new folder. This has been...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.