473,659 Members | 2,645 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 1903
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.co m

"Jason" <Ja***@mobiform .com> wrote in message
news:e%******** *******@TK2MSFT NGP09.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.co m>
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 CreateFromGraph icsPath( 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.Pa thPoints.Length ; i++ )
{


GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[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_CachedIsSimpl e = -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.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.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.co m

"Jason" <Ja***@mobiform .com> wrote in message
news:e%******** *******@TK2MSFT NGP09.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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
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.co m>
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 GetGraphicsPath TypeInfo( byte pathType, ref bool bCloseSubPath, ref bool bLine, ref bool bBezier )

{

bCloseSubPath = ( pathType & (byte)PathPoint Type.CloseSubpa th ) > 0;

if ( bCloseSubPath )

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

pathType = (byte)(pathType & (~(byte)PathPoi ntType.CloseSub path));

}

bLine = ( pathType == (byte)PathPoint Type.Line );

bBezier = ( pathType == (byte)PathPoint Type.Bezier );

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

// bool bBezier3 = ( pathType == (byte)PathPoint Type.Bezier3 );

}

"Jason" <Ja***@mobiform .com> wrote in message news:uY******** *****@TK2MSFTNG P10.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 CreateFromGraph icsPath( 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.Pa thPoints.Length ; i++ )
{


GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[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_CachedIsSimpl e = -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.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.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.co m

"Jason" <Ja***@mobiform .com> wrote in message
news:e%******** *******@TK2MSFT NGP09.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.co m>
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 CreateFromGraph icsPath( 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.Pa thPoints.Length ; i++ )
{
GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );

if ( bBezier )
{
//this is a bezier point, solve for linear segments
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
i+=2;
//re-evaluate point type to see if we need to close
GetGraphicsPath TypeInfo( (byte)graphicsP ath.PathTypes[i], ref bCloseSubPath, ref bLine, ref bBezier );
}
else
{//just a line point ... I assume

polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[i-1]) );
if ( bCloseSubPath && bLine )
{
polygon.AddPoin t( new Point2D(graphic sPath.PathPoint s[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_CachedIsSimpl e = -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.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.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.co m

"Jason" <Ja***@mobiform .com> wrote in message
news:e%******** *******@TK2MSFT NGP09.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
1442
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 80 chars or so, if that matters. I figured I'd set the attribute on the object and on the ArrayList and use standard Serialize() functions. This is just incredibly slow. Is that normal? Any other recommended approach? The function itself...
6
3001
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 function to count lines in a large file that start with a particular pattern. The file can contain large amounts of non-text crap, which may make some lines very long (so using getline() with a std::string isn't feasable). So I dug around looking...
10
3201
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 layer behind the menus. The closer div has a lower index than the submenu divs so it appears behind them. The closer div contains a transparent gif with an event applied to it to close all of the divs when moused over.
0
1130
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 the ADp. In Query Analyzer, I can't duplicate the lags, and on machines running SP1 performance continues to be good. I'd like to keep the service packs in place, but performance is unacceptable. Any suggestions appreciated. Thanks,
0
1127
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 designing reports considerably and it didn't used to occur in previous versions. I have macro security set to low. I have tried uninstalling/reinstalling with no success. Any ideas? Thanx in advance.
7
2156
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 record source for my form is an ODBC passthrough query to an Oracle database. I have two XP system identically configured except that one has Access 2000 and the other with Access 2003. I only have this problem with Access 2003. The Access 2003...
0
824
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 (this is in a block that's reading data). mFieldValues = String.Format(" Values({0},""{1}"",""{2}"",""{3}"",""{4}"")", _ .GetInt32(0), .GetString(1), .GetString(3), .GetString(4),
2
1174
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 ones, etc. Any ideas? Users in my company are reporting slowness in MS Word as well. We also have Lotus Notes.
9
1165
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: # print line
0
987
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 happening for a while now but I don't remember it always being this way. I tried to find the broken shell using shellExView but the only thing that shows a problem is the google toolbar in IE. I disabled that rebooted my PC and still get the same...
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8539
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.