帮助解决15,000行批处理过程 [英] Help on sppeding up a 15,000 line batch process

查看:78
本文介绍了帮助解决15,000行批处理过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows应用程序中,我正在运行一个批处理过程,该过程由一个FOR循环

组成,它将运行15,000次(数据行数),复制数据每个

row -3 fields-到一个struct,并将strct发送到一个外部方法(使用

DLLImport)。问题是处理速度非常不一致 -

它可能会在某些时间段内非常快速地运行但是它会在其他时刻(特别是当它''时运行非常缓慢到达表的最后:

12,000条记录)。我知道速度,因为我在表单中显示了一个计数器

(带有Application.DoEvents())。我已经淘汰了

DoEvents但它仍然不一致。


这是以前在MS中制作的应用程序的新版本

C / C ++。我的C#应用​​程序与之前版本之间的唯一区别

(除了它所写的语言)是我必须在C#中重新创建

结构(外部方法接收作为参数并修改)

并且我使用DLLImport作为方法。这会是为什么这么慢的原因吗?此外,运行时内存使用率(在任务管理器中)为100%。


谢谢,

VM

解决方案

我可以建议您连接一个分析器,看看问题出在哪里......


很可能是Interop问题但很困难没有来源告诉

代码等...


有一些非常好的个人资料,大多数都有30天的试用期

:-)

欢呼,

g


" VM" < VO ****** @ yahoo.com>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

在我的Windows应用程序,我正在运行一个批处理过程,它由一个FOR
循环组成,它将运行15,000次(数据行数),复制每行
行-3字段的数据 - 到一个结构,并将strct发送到外部方法
(使用DLLImport)。问题是处理速度非常不合理 - 它在某些点上运行得非常快,但是在其他时刻它运行非常慢(特别是当它到达表的末尾时) :之后有12,000条记录)。我对速度有所了解,因为我在表单中显示了一个计数器
(带有Application.DoEvents())。我已经淘汰了DoEvents的
,但它仍然不一致。

这是以前在MS / C / C ++中制作的应用程序的新版本。我的C#应用​​程序与之前版本之间的唯一区别
(除了它编写的语言之外)是我必须在C#中重新创建
结构(外部方法接收为参数和
修改)并且我使用DLLImport作为方法。这会是为什么
这么慢的原因?此外,运行时内存使用率(在任务管理器中)为100%。

谢谢,
VM



感谢您的回复。 interops会自然地使系统变慢吗或者b / b $ b b这会是我的代码吗?换句话说,速度是否可以提高或者是否为净点限制?


VM


Gary Hunt <是******* @ codequest.co.uk>在消息中写道

新闻:#x ************* @tk2msftngp13.phx.gbl ...

我可以建议你勾一个探查器,看看问题出在哪里......

有可能是一个Interop问题但很难说没有
源代码等......

欢呼,


>VM < VO ****** @ yahoo.com>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

在我的Windows应用程序中,我''正在运行一个由FOR


循环

组成的批处理过程,它将运行15,000次(数据行数),复制每个数据
行-3字段 - 到结构,并将strct发送到外部方法


(使用

DLLImport)。问题是处理速度非常


不一致 -

它可能在某些点上运行非常快但是在其他时刻它运行非常慢(特别是当它到达表的末尾时:在12,000条记录之后
)。我对速度有所了解,因为我有一个计数器


在表单中显示

(使用Application.DoEvents())。我已经淘汰了


DoEvents但它仍然不一致。

这是以前的应用程序的新版本用MS制作
C / C ++。我的C#应用​​程序和之前版本之间的唯一区别
(除了它编写的语言)是我必须在C#中重新创建
结构(外部方法作为参数和
修改)

并且我使用DLLImport作为方法。这是


它的

这么慢的原因吗?此外,当
运行时,内存使用率(在任务管理器中)为100%。
谢谢,
VM




我想这取决于有问题的Interops!


如果您认为通过那么一些Interop操作当然可以

调整 - 例如 - 如果你有一个100MB的字符串数据,并且你是通过Interop传递它的b $ b,那么以下情况就是这样:
< br。>
1. .Net将它的字符串存储为Unicode

2.调用ANSI Interop函数需要将那些

字符串转换为ANSI并且从Interop调用

3.这比调用UNICODE Interop函数慢得多


我认为上面的例子显示了Interop如何能够要比原始C ++慢b / b
,但还有很多其他因素。根据我的通话经验

Interop我没有注意到任何特别的减速因此,探查器会确定哪一行代码导致问题。


它也可能是一个GC问题 - 为什么你不发布基本代码,它可能会显而易见(或者可能不会!) )


欢呼,


g

" VM" < VO ****** @ yahoo.com>在消息中写道

新闻:e6 ************** @ TK2MSFTNGP09.phx.gbl ...

感谢您的回复。 interops会自然地使系统变慢或者它会与我的代码有关吗?换句话说,速度是可以提高还是点网限制?

VM

Gary Hunt <是******* @ codequest.co.uk>在消息中写道
新闻:#x ************* @tk2msftngp13.phx.gbl ...

我可以建议您将分析器连接到看看问题出在哪里......

如果没有


source

code等,很可能会出现Interop问题。 ..

有一些非常好的剖析器,大多数都有30天的
试验

: - )
            < VO ****** @ yahoo.com>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

在我的Windows应用程序中,我''正在运行一个批处理过程,它由
FOR

loop

组成,它将运行15,000 times(数据表行数),将每个
row -3字段的数据复制到struct,并将strct发送到外部方法


(使用

DLLImport)。问题是处理速度非常


不一致 -

它可能在某些点上运行非常快但是它运行非常慢


at其他时刻(特别是当它到达表的末尾时:


在12,000条记录之后)。我对速度有所了解,因为我有一个计数器


在表单中显示

(使用Application.DoEvents())。我已经消除了

DoEvents但它仍然不一致。

这是以前在MS中制作的应用程序的新版本
C / C ++。我的C#应用​​程序与之前的


版本(除了编写的语言之外)之间的唯一区别是我必须在C#中重新创建
结构(外部方法作为参数接收)和


修改)

并且我使用DLLImport作为方法。这是一个原因


为什么它的

这么慢?此外,当


运行时,内存使用率(在任务管理器中)为100%。
谢谢,
VM





In my Windows app, I''m running a batch process that''s composed of a FOR loop
that''ll run 15,000 times (datatable row count), copy cthe data of each
row -3 fields- to a struct, and send the strct to an external method (using
DLLImport). The problem is that the processing speed is very inconsistent-
it may run very FAST during certain points but then it runs VERY slow at
other moments (especially when it''s getting to the end of the table: after
12,000 records). I have an idea of the speed because I have a counter being
displayed in the form (with an Application.DoEvents()). I''ve eliminated the
DoEvents but it''s still inconsistent.

This is a new version of an application that was previously made in MS
C/C++. The only differences between my C# app and the previous version
(besides the language it was written in) is that I had to recreate the
struct in C# (which the external method receives as parameter and modifies)
and that I use the DLLImport for the method. Would this be a reason why it''s
so slow? Also, the memory usage (in Task Manager) is at 100% when running.

Thanks,
VM

解决方案

Can I suggest you hook up a profiler to see where the problem lies...

Chances are it''s a Interop problem but difficult to tell without the source
code etc...

There are some very good profilers out there and most have a 30 day trial
:-)

cheers,

g

"VM" <vo******@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

In my Windows app, I''m running a batch process that''s composed of a FOR loop that''ll run 15,000 times (datatable row count), copy cthe data of each
row -3 fields- to a struct, and send the strct to an external method (using DLLImport). The problem is that the processing speed is very inconsistent- it may run very FAST during certain points but then it runs VERY slow at
other moments (especially when it''s getting to the end of the table: after
12,000 records). I have an idea of the speed because I have a counter being displayed in the form (with an Application.DoEvents()). I''ve eliminated the DoEvents but it''s still inconsistent.

This is a new version of an application that was previously made in MS
C/C++. The only differences between my C# app and the previous version
(besides the language it was written in) is that I had to recreate the
struct in C# (which the external method receives as parameter and modifies) and that I use the DLLImport for the method. Would this be a reason why it''s so slow? Also, the memory usage (in Task Manager) is at 100% when running.

Thanks,
VM



Thanks for your reply. Would interops naturally make the system slower or
would it be something with my code? In other words, can the speed be
improved or is it a dot net limitation?

VM

"Gary Hunt" <be*******@codequest.co.uk> wrote in message
news:#x*************@tk2msftngp13.phx.gbl...

Can I suggest you hook up a profiler to see where the problem lies...

Chances are it''s a Interop problem but difficult to tell without the source code etc...

There are some very good profilers out there and most have a 30 day trial
:-)

cheers,

g

"VM" <vo******@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

In my Windows app, I''m running a batch process that''s composed of a FOR


loop

that''ll run 15,000 times (datatable row count), copy cthe data of each
row -3 fields- to a struct, and send the strct to an external method


(using

DLLImport). The problem is that the processing speed is very


inconsistent-

it may run very FAST during certain points but then it runs VERY slow at
other moments (especially when it''s getting to the end of the table: after 12,000 records). I have an idea of the speed because I have a counter


being

displayed in the form (with an Application.DoEvents()). I''ve eliminated


the

DoEvents but it''s still inconsistent.

This is a new version of an application that was previously made in MS
C/C++. The only differences between my C# app and the previous version
(besides the language it was written in) is that I had to recreate the
struct in C# (which the external method receives as parameter and


modifies)

and that I use the DLLImport for the method. Would this be a reason why


it''s

so slow? Also, the memory usage (in Task Manager) is at 100% when running.
Thanks,
VM




I guess that depends on the Interops in question!

If you think it through then some Interop operations could certainly be
tuned - for example - if you''ve got a 100MB of string data and you''re
passing it through Interop then the following would be true:

1. .Net stores it''s string as Unicode
2. Calling an ANSI Interop function would require converting those
strings to ANSI to and from the Interop call
3. That''s got to be slower than calling a UNICODE Interop function

I think the example above shows how Interop could be slower than the raw C++
but there are so many other factors involved. In my experience of calls via
Interop I haven''t noticed any particular slow down so the profiler would
certainly identify which bit of code is causing the problem.

It could also be a GC issue - why don''t you post the basic code and it may
be obvious (or probably won''t be!)

cheers,

g
"VM" <vo******@yahoo.com> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl...

Thanks for your reply. Would interops naturally make the system slower or
would it be something with my code? In other words, can the speed be
improved or is it a dot net limitation?

VM

"Gary Hunt" <be*******@codequest.co.uk> wrote in message
news:#x*************@tk2msftngp13.phx.gbl...

Can I suggest you hook up a profiler to see where the problem lies...

Chances are it''s a Interop problem but difficult to tell without the


source

code etc...

There are some very good profilers out there and most have a 30 day trial

:-)

cheers,

g

"VM" <vo******@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

In my Windows app, I''m running a batch process that''s composed of a FOR

loop

that''ll run 15,000 times (datatable row count), copy cthe data of each
row -3 fields- to a struct, and send the strct to an external method


(using

DLLImport). The problem is that the processing speed is very


inconsistent-

it may run very FAST during certain points but then it runs VERY slow

at other moments (especially when it''s getting to the end of the table:


after 12,000 records). I have an idea of the speed because I have a counter


being

displayed in the form (with an Application.DoEvents()). I''ve eliminated the

DoEvents but it''s still inconsistent.

This is a new version of an application that was previously made in MS
C/C++. The only differences between my C# app and the previous

version (besides the language it was written in) is that I had to recreate the
struct in C# (which the external method receives as parameter and


modifies)

and that I use the DLLImport for the method. Would this be a reason

why it''s

so slow? Also, the memory usage (in Task Manager) is at 100% when


running.
Thanks,
VM





这篇关于帮助解决15,000行批处理过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆