dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: when generate 10000 matrix bar code it take too much time How to make generating take

  1. #1
    Join Date
    Dec 2016
    Posts
    13

    when generate 10000 matrix bar code it take too much time How to make generating take

    Problem

    When generating matrix 2d bar code it take per 10000 files matrix bar code generating it take 1 minute
    so that how to generating matrix bar code 2d in less time as seconds .
    my code as below under button generating :

    Code:
    Class1 CLS = new Class1();
                    DataTable dt = CLS.ShowalldataSerial(textBox4.Text);
    
                    for (int i = 0; i <= Convert.ToInt32(textBox1.Text); i++)
                    {
                        Serial = SRL.Rnd().ToString();
                        txt = "UserID" + dt.Rows[0][0] + "FirmName" + dt.Rows[0][1] + "OrderNo" + dt.Rows[0][2] + "BtachNo" + dt.Rows[0][3] + "Quantity" + dt.Rows[0][4] + "ProductName" + dt.Rows[0][5] + "SerialNo" + Serial;
    
                        dm.DM(txt, Color.FromName(comboBox1.SelectedItem.ToString()), Color.White).Save(root + "\\" + Serial + ".emf", System.Drawing.Imaging.ImageFormat.Emf);
    
                    }
                    MessageBox.Show("Records generated success ");

    when create 10000 in textbox1 it take minute if i write

    200000 in textbox1 it take 20 minutes

    Code working without any problem and give me result what i need

    but it slowly generating data matrix per big quantities

    so that what i do to make generating matrix bar code very fast .

  2. #2
    Join Date
    Feb 2017
    Posts
    508

    Re: when generate 10000 matrix bar code it take too much time How to make generating

    Quote Originally Posted by ahmed.barbary View Post
    so that what i do to make generating matrix bar code very fast .
    You first must find out what is making it slow.

    Although string manipulations can slow things down I suspect the problem is within the dm.DM method. To verify this I suggest you evaluate all parameters of dm.DM and assign them to variables which you pass to dn.DM. The code should work exactly as before.

    You then comment out dm.DM so it is not called and run the program again to check what happens. If it is now much faster you know the performance bottleneck is inside dm.DM and that this is the code you must improve. If it still is slow as before you know the problem is the loop and most likely the string processing. In that case all you can do is move everything that does not change between iterations out of the loop. The compiler should do this for you as an optimization but you can always do it yourself in case it doesn't get done for some reason.
    Last edited by wolle; May 16th, 2017 at 09:16 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)