Matrix performance

I got an 2049x2049 matrix which represents an detector image. I analyse my measured data in a while loop and every time I find a detector event I increase the corresponding matrix cell about one. But this process is awful slow. Approx. 5min for 2500 counts. I used the profiler to determine which part of the code inside the loop causes the delay, but every bit is running fast, but not the whole loop. I use shift register to pass the matrix in the next loop step, so I presume this is the part where I lose time.
Is there a better way passing a matrix through a loop ?
I know of text based programming languages that you adress such a matrix as global variabel because of efficiency aspects. Is there something similar possible in LabVIEW 7 ?
The
attached VI contains the descript code as example. It is not able to run because it is a smaller part of larger VI.
Thanks in advance for your help
Attachments:
passingMatrix.vi ‏66 KB

When you run it, is it the inner loop that is slow (I see you have an indicator on the index), or is it the outer? Without a data source it's not easy to do any tests.
Shift registers are the fastest option and your code looks OK as far as I can see.
You could perhaps use a presized stack in a functional global instead of the que. The que status VI should be linked to the deque function so that you don't get a race condition (currently there is no guaranteed execution order). Are you sure it's not the ques the code it waiting for? Unless the que contains new data everytime the loop has done an iteration (which should be fast) the loop will stop and wait for new data to arrive...You could perhaps get rid of the local of the time has passed and some other
minor stuff, but that would not explain the problem here.
MTO

Similar Messages

  • JAI and grayscale problems

    Hi!
    My problem concerns grayscale. First I load tiff-image from a file (OK) and then I want to change its colors to grayscale and after that I save that converted picture as Bmp, but this is not working. I have tried codes that I found from forum, but those arent helping me.So, in brief how to convert tiff image to grayscale image and sav it as Bmp. Could anyone give me a code? This grayscale seems to be problem for many people.

    You can convert tiff image to grey image by:
    public PlanarImage convertColor(PlanarImage src_image){
    double[][] matrix = {
    { .114D, 0.587D, 0.299D, 0.0D }
    // Create the ParameterBlock.
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(src_image);
    pb.add(matrix);
    // Perform the band combine operation.
    return (PlanarImage)JAI.create("bandcombine", pb, null);
    Write you codes like this:
    PlanarImage srcc=convertColor(planarImage);
    BMPWriter bmpW=new BMPWriter(srcc,fc.getCurrentDirectory().getPath(),file.getName());               bmpW.saveImage();
    Following is class used for save image to bmp
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import java.io.*;
    import javax.media.jai.*;
    import javax.media.jai.widget.*;
    import com.sun.media.jai.codec.*;
    import javax.swing.*;
    public class BMPWriter {
         private PlanarImage src;
         private String outFilePath;
         private String outFileName;
    private ImageEncoder encoder = null;
         BMPEncodeParam encodeParam=null;
    // Create the image encoder.
    private void encodeImage(PlanarImage img, FileOutputStream out)
              ImageEncoder encoder = ImageCodec.createImageEncoder("BMP", out,
    encodeParam);
              if (encoder==null){
                   System.out.println("encoder is null");
                   return;
              if (img==null){
                   System.out.println("img is null");
                   return;
              try {
    // encoder.encode(img);
                        encoder.encode(img);
    out.close();
              catch (IOException e) {
    System.out.println("IOException at encoding..");
    System.exit(1);
    private FileOutputStream createOutputStream(String outFile) {
    FileOutputStream out = null;
    try {
    out = new FileOutputStream(outFile);
    } catch(IOException e) {
    System.out.println("IOException.");
    System.exit(1);
    return out;
    public BMPWriter(PlanarImage img,String outFilePath,String outFileName) {
              this.outFilePath=outFilePath;
              this.outFileName=outFileName;
              src=img;
         public void saveImage(){
              FileOutputStream out1 = createOutputStream(outFilePath+File.separator+outFileName);
              if (out1==null){
                   System.out.println("out1 is null");
                   return;
    double[] constants = new double[3];
    constants[0] = 0.0;
    constants[1] = 0.0;
    constants[2] = 0.0;
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(src);
    pb.add(constants);
              encodeParam = new BMPEncodeParam();
    encodeImage(src, out1);
    }

  • How to build a performance matrix report

    Hi,
    I have a table that tracks performance and potential of employee's.
    I want to represent the data in the table as a 9 box performance potential matrix report Each box should contain the names of the employees who fit the particular performance potential criteria.
    |---------------|--------------|-----------------| ^
    | | | | p
    | | | |Exceeds e
    | | | | r
    |---------------|--------------|-----------------| f
    | | James | | o
    | | Dan | |Meets r
    | | | | m
    |---------------|--------------|-----------------| a
    | | | | n
    | | | |Needs Improvement c
    | | | | e
    |---------------|--------------|-----------------|
    Limited Growth High
    <-------------Potential---------------------->
    Is there a good way of achieving this?

    http://download.oracle.com/docs/cd/B14099_17/bi.1012/b13895/orbr_plsql.htm#g1021942

  • Matrix report performance

    Hi,
    I have a table with the following attributes : item, location, value. I want to create a matrix report with items on columns, locations as headers and in the middle the correspondent values: the report should look like this:
    item loc1 loc2 loc3
    1234 200 300
    2456 25 12
    456 12 15 16
    I know how to do the matrix report(I use a view based on the table) but my question is related to a performance problem. As the view contains a lot of data (more than 2mil. records), my question is how the matrix report is being build( I need to know if it does a self-join with the same view to build it, as this might take a long time to generate the report).
    In case I use a parameter for location(for example I want to generate a matrix report but only for loc1) it will take a long time as well?
    Thanks

    Try to avoid too much of regrouping in layout, have your xml structure in desired format. Also try enabling scalable mode

  • Using Shading Dictionary to perform shading in pdf,before that the shading dictionary call from Pattern Dictionary.In the Pattern Dictionary there is an Matrix based on the matrix value  location the shading operatihow the axial shading is preserve in pdf

    using Shading Dictionary to perform shading in pdf,before that the shading dictionary call from Pattern Dictionary.In the Pattern Dictionary there is an Matrix based on the matrix value  location the shading operation is perform,So i dont know how to calculate value of pattern Dictionary matrix value.
    10 0 obj
    << /Type /Pattern
    /PatternType 2
    /Shading 11 0 R
    /Matrix [1.00 .00 .00 1.00 54.00 53.00]  // the matrix value how to calculate
    >>
    11 0 obj
    <<
    /ColorSpace /DeviceRGB
    /Function 12 0 R
    /ShadingType 2
    /Coords [109.2726 69.00 109.2726 .00]
    /Extend [true true]
    >>
    12 0 obj
    <<
    /FunctionType 0
    /Domain [.00 1.00]
    /Range [.00 1.00 .00 1.00 .00 1.00]
    /Size [1002]
    /BitsPerSample 8
    /Length 3006
    >>
    stream
    here is an stream of colors
    endstream
    endobj
    Can anybody help me please.
    Regards, Sasi kumar sekar.

    Hi, Sasi -
    The Matrix maps coordinates in your shading dictionary into User Space. That is, the Matrix entry in the Pattern dictionary specifies a coordinate transformation that will be applied to coordinates specified in the shading dictionary.
    To take your example, you have an axial shading extending from (rounding off) 109,69 to 109,0.  Your Pattern dictionary specifies the Matrix
    [ 1  0  0  1  54  53 ]
    This transformation matrix corresponds to a scale of 1,1 (that is, no change in scale) and a translation of 54,53. Thus, the actual endpoints for the axial shading will be the User Space positions 163,122 and 163,53 (assuming I’ve added correctly).
    As to what values to use for your Matrix, it depends on how you’ve set up your Shading dictionary. If the coordinates you’ve specified are actually where you want the gradient to go, then just use an identity matrix
    [ 1  0  0  1  0  0 ]
    By the way, are you sure that the Pattern dictionary includes a Matrix entry? I seem to remember (it's been a while since I've looked at Patterns) that the matrix is supplied as an argument to the makepattern operator:
    <<patternDict>> [ 1 0 0 1 0 0 ] makepattern
    Hope that helps.
    - John Deubert
      Acumen Training
      PostScript and PDF
      Training & Consulting

  • How fast does Labview perform integer, float and matrix calculations?

    What is the speed of a modern CPU? Ok it is 3Ghz, one to four cores etc. but how much work can I get done in one clock cycle at this speed?
    This kind of questions have been in the back of my head for some time, so I decided to test it. Of course using Labview since it so easy to to use!
    I wrote a really simple program that performed 10000 adds 3 to an 32 bit integer in a loop. It then repeats this until 1000ms has elapsed and calculates the MegaInts (or whatever I should call it). I then did the same thing by adding 3 to a matrix of 10000 32bit ints.
    On and dual core 3Ghz PC from 2005 I got 261 Mints in a loop, and 1400 Mints in matrix. Only one core seems to be used, CPU load aorund 50%. So every two clock cycles or so I get some work done in a matrix calculation. Also older 1,8Ghz Celeron computers performs about the same in this test, even though they feel very slow in normal use.
    On a newer 4/8 core 2,8Ghz PC from this year I got 830 Mints in a loop, and 5900 Mints in matrix. Only one core seems to be used, CPU load aorund 12%. So actually more than one add per clock cycle!
    This indicates that either the compiler is smarter than me and does not to all integer adds, or the CPU is smart and do them very fast!
    See this as not the complete benchmark of Labview in integer, float and matrix calculations, but as a teaser to make you do your own tests.
    Play around and have fun!

    Norbert_B wrote:
    Yamaeda wrote:
    A standard loop only runs in 1 thread,[...]
    That is not true.
    A standard loop follows the clumping algorithm during compilation. Clumps can be distributed on any number of threads.
    So, a standard loop CAN be distributed between several threads.
    There are, however, some settings and structures which will result in a single thread per loop:
    - Setting the calling VI to "subroutine" priority (not recommended)
    - Using a Timed Loop instead of a standard one
    - AFAIK: Containing the loop in an InPlace Element Structure with "Data Value Reference" border nodes
    There is at least one additional option, but it is so unlikely (as it messes up with most of LV!) that i will not point it out here.....
    Norbert
    Why would we have parallellization options for a loop if it's already multithreaded? I'd love if loops would automatically parallellize.
    If you mean the content inside the loop, then it'll follow ordinary optimization and use several threads if possible. In this case OP mentioned 1 cpu was at 100%.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Slow performance when reading a system matrix

    Hi
    I have written a program for sbo 6.5 which reads the matrix in sales order processing which contains the lines of the sales order.
    The program works fine but if the user enters in a large order of over say 50 items the system is quite slow reading all the lines. The more lines in the order the slower it gets. I was thinking about performing an sql query but this won't work when someone enters a new order as the order will not be written to the file
    I am simply looping through the lines of the matrix reading the fields I need on each line
    Can anyone suggest a way of speeding this up please
    Regards Andy

    Andy/Paul,
    Have you checked the 'SAP Business One UI API 6.5 Performance Tips'?
    It says:
    "Updating and getting values of form items is more efficient when you access the item via its bound UserDataSource object instead of its properties. This is especially true for matrixes containing many items.
    -snip-
    To get matrix data, call the GetLineData(Row) method and Value property of the UserDataSource.Value bound to the column."
    Depending on how you loop, and what you do while looping, Form.Freeze(True/False) might help, too.
    HTH Juha

  • Slow performance on updating B1 matrix..

    hi,
    I am updating data in B1 matrix. It take about 7 seconds to update 5 columns. Anyone know how to make it faster?
    Thanks.
    Regards,
    sohch

    Hi,
    I'm also missing the possibility of using the (db-)datasources on SAP forms for writing.
    Do you use the event filters in your addon? With this you can restrict the event types per form-type, which your add-on accepts.
    If your add on ONLY needs key-down and pressed-item events on form 149 for example you must say (when starting the addon):
    Dim oFilters As SAPbouiCOM.EventFilters
    Dim oFilter As SAPbouiCOM.EventFilter
    oFilters = New SAPbouiCOM.EventFilters
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_KEY_DOWN)
    oFilter.AddEx("149")
    ....add more forms for "key down" if needed...
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED)
    oFilter.AddEx("149")
    ....add more forms for "pressed items" if needed...
    SboUI.SetFilter(oFilters) ' SboUI is the SAPbouiCOM.Application
    From now on you must activate every event in filters.
    Maybe this gives you a little performance kick...

  • UI: Matrix - Slow Performance, Urgent

    Hi:
    We are having problems with the performance of the Matrix.
    We are developing with Visual Basic 6.0.
    SAP Business One 6.50.50 SP:01 EF:07.
    We are using DataBinding and UserdataSources to fill the Matrix because this is the best option, but the performance is slow.
    We have a Matrix with 8 columns and we have problems with the performance of load rows into the matrix.
    We load items and we have the below results:
    For 1,000.00 Items or Rows the time is 7 seconds.
    For 2,000.00 Items or Rows the time is 15 seconds.
    For 3,000.00 Items or Rows the time is 20 seconds.
    For 4,000.00 Items or Rows the time is 27 seconds.
    For 5,000.00 Items or Rows the time is 34 seconds.
    For 8,000.00 Items or Rows the time is 52 seconds.
    For 10,000.00 Items or Rows the time is 1:08 minutes.
    and we can calculate for 50,000 and 100,000 rows.
    Our customers have 50,000 or more items.
    Our matrix is into a windows that we are using for search items, and we need one faster method for dislay the items into matrix because this is a big problem now.
    We want to know if the Matrix have limits of number of rows.
    Some of our customers have 100,000.00 records on Item Master Records, with this performance the real time 113 minutes to load all rows into the matrix.
    In a normal screen of SAP Business One we don´t have problems, but in our screen we have a slow performance.
    What is the limit of rows into the Matrix ?

    Hi Plácido,
    I cannot give you a real good advice for 6.5
    Running a select that fills a UDT + then displaying the content with DBDataSource will maybe not be much faster.
    But in version 2004 this should be really fast as DBDataSources will be much better usable:
    You can fill a matrix in one go (no iteration record be record necessary anymore) + you can access the contents of the DBDataSource + even add/remove lines!
    This is only for non-system (i.e. B1) forms, but maybe could help you.
    Maybe you should wait for that, if it could be a way to fulfill the logical requirements.
    Regards,
    Frank

  • Matrix report in BI publisher performance

    HI Team,
    I have build RTF layout for matrix report,the data generation is completing in very less time.. but the layout swapping the rows as columns taking too long time , If data generation is completing around 5 mins..layout building is completing in 45 mins.. Please let me know any feasable solution.
    Best Regards.
    Edited by: user9100912 on Mar 28, 2013 6:41 AM

    Try to avoid too much of regrouping in layout, have your xml structure in desired format. Also try enabling scalable mode

  • How do I reference a cell in a matrix that performs the aggregate?

    Assuming I have a Matrix such as:
    Year
    Customer Name SUM(sales amount)
    ... and the text control the aggregate takes place in (the sum function) is named "matrix1_tb_sum"...
    After the report is executed, there will be a column for each year.  Let's say 2013 and 2014 both return.
    What will be the name of the text control for each year?  If I reference "ReportItems!matrix1_tb_sum.Value" from any scope it returns the value of the "right most" column grouping.  How do I reference other column groupings?
    My goal is to add out-of-grouping columns to the right to show additional data, but I don't want to re-type the formulas.  For example, I would add an out-of-group column to the right and add something like:
    =ReportItems!matrix1_tb_sum[2014].Value - ReportItems!matrix1_tb_sum[2013].Value
    ...to show the difference between the two columns without making a SUM IIF.

    Hi Mini Button,
    Base on your description, you have a matrix in your report which you want to add an aggregation field of the Sales Amount for each year and finally add an column to show the difference between two years. Right?
    In Reporting Service, if we want to compare values of two adjacent columns in a matrix, the best way is using custom code to deal with the logic. I have tested in our local environment. In this scenario, we can compare the current value with previous value.
    The difference value is always along with columns generated. So we suggest put this column inside of group instead of appending them at the end of the matrix. In this column, we can call the function defined in the custom code. Here are steps and screenshots
    for your reference:
    Custom code:
    Put the custom code into report:
    Private queueLength As Integer = 2
    Private queueSum As Double = 0
    Private queueFull As Boolean = False
    Private idChange As String=""
    Dim queue As New System.Collections.Generic.Queue(Of Integer)
    Public Function CumulativeQueue(ByVal currentValue As Integer,id As String) As Object
    Dim removedValue As Double = 0
    If idChange <> id then
    ClearQueue()
    idChange = id
    queueSum = 0
    queueFull = False
    CumulativeQueue(currentValue,id)
    Else
    If queue.Count >= queueLength Then
    removedValue = queue.Dequeue()
    End If
    queueSum += currentValue
    queueSum -= removedValue
    queue.Enqueue(currentValue)
    If queue.Count < queueLength Then
    Return Nothing
    ElseIf queue.Count = queueLength And queueFull = False Then
    queueFull = True
    Return (queueSum-currentValue-currentValue)
    Else
    Return (queueSum-currentValue-currentValue)
    End If
    End If
    End Function
    public function ClearQueue()
    Dim i as Integer
    Dim n as Integer = Queue.Count-1
    for i=n To 0 Step-1
    queue.Dequeue()
    next i
    End function
    Click the report Properties and click the “Code” than add above custom code in it, click ok.
    Create a matrix based on your information. Put expression into corresponding positions:
    Expression in the first row: =IIF(Previous(Fields!Year.Value) is nothing,"",IIF(Previous(Fields!Year.Value) is nothing,1,Previous(Fields!Year.Value))&" - "&Fields!Year.Value)
    Expression in the second row: =Code.CumulativeQueue(Fields!SalesAmount.Value,Fields!CustomerName.Value))
    Expression in the third row: =Code.CumulativeQueue(sum(Fields!SalesAmount.Value),Fields!CustomerName.Value)
    Note : You may need to modify the custom code and expression based on the data type in your dataset.
    Save and preview. It looks like below:
    Below similar threads are for your reference:
    SSRS 2008 R2 - Add moving average to column group
    Difference Between the grouped column
    If you still have any question, please feel free to ask.
    Regards
    Vicky Liu

  • Slow performance whith user form matrix using UserDataSources

    Hello,
    I have a matrix with ~5 columns for weeks OR ~30 columns for days. I´m using UserDataSources and it is very slow to fill the matrix, it takes ~0.8 seconds per line with 5 columns and ~1.7 seconds per line with 30 columns (with no over head of values calculation).
    I tried using a auxiliary User Table to be able to use DBDataSources but improves only 4 seconds (with 5 columns, from 12 seconds of the userdatasources) to 10 seconds (with 30 columns, from 50 seconds of the userdatasources) in my small test of only a dozen lines.
    With the over head of the calculation (using RecordSets to read values from other tables) it is very slow.
    I have read other answers in the forum and they say to use datasources but that is wath i am doing!
    Any suggestions, PLEASE?
    Jorge Lopes

    Edward,
    Had already seen it, but thank you for the answer anyway.
    I would like to know if the times i gave are normal or to slow (anyone from SAP?).
    I saw a post where they said they filled 1000 lines with 8 columns in 7 seconds, must be only DBDataSource not with UserDataSources!!!
    Jorge Lopes

  • Want Document about performance matrix for WLS 5.1,6.1,7.0 and 8.1

    hi,Guys
    Where can I find the document about weblogic 5.1,6.1 , 7.0 and 8.1
    server performace matrix? currently we want to update our system from
    5.1 to the most recent WLS, everyone know WLS 8.1 is running faster than
    5.1, who can tell me how faster it can be based on very generically way.
    thanks,
    Roy

    Where can I find the document about weblogic 5.1,6.1 , 7.0 and 8.1
    server performace matrix?Roy asks a great question - and I've been searching Weblogic site for the info
    myself.
    From a management perspective, it takes time and money to upgrade to the latest
    WLS.
    I need to put together a business case for management illustrating a Cost/Benefits
    analysis.
    If I can point to sources were people upgraded from 5.1/1.3.1 to 8.0/1.3.1 and
    achived an XX% increase; then I can relate that to the cost of upgrading hardware/etc
    - and better decide where to spend the money.
    If anybody has the numbers or experience - I'd love to hear from you.
    Thanks

  • SSRS Matrix report. Variance expression by Month. Need to compare month from prior year to current month of current year VS2010

    Please help.  I have a matrix report.  In the report I have row group  PO Type.  One the Column groups I have a parent group by Fiscal Year, and then a child group by Month.  When I run the report, I get two years of data back broken
    out by month.  Please see below.
    Now here is where I am getting stuck.  I need to take the variance between the current month of the current year, from the same month of the prior year.  So I need to show the difference between Oct , 2014 from Oct, 2013. November, 2014 from November
    2013... etc. etc.
    In the example below, how do I create a column or row showing the variance for Contracts for October 2014.  I need to take the contracts for October 2014 which is 3 and subtract that from October 2013 which is 8.  Any suggestions? How do I do that
    for each month?  Then I need to do it for the quarter... then the year?  But I'll be happy if I can just get the month working first.
    Any help will be appreciated. 
    here is what my rdl file looks like.
    Here is what my report looks like when I render it.

    Hi Adrian_s2012,
    According to your description, you want to compare values for the month of current year with the month of prior year and get the variance. Right?
    In Reporting Services, we don't have any function to get this "Year to Year" Growth. In this scenario, if you data source is a cube, we suggest you use Analysis Services to achieve your requirement. If this data source is just from database, it will be hardly
    to calculate the variance because we need to compare the values within every two different column group and matrix generate adjacent columns one by one. Even we make it by using custom, every time executing the long code when generating result
    in a cell will reduce a lot of performance, we really don't suggest to do that in SSRS. Here is a thread with much easier requirement, please take a reference of that:
    http://social.msdn.microsoft.com/Forums/office/en-US/842e2dcb-d949-4297-9d91-eac989692cb5/difference-between-the-grouped-column?forum=sqlreportingservices
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Crystal Report speed problem on dot matrix printers

    We are attempting to print marketing documents (sales orders) to a dot matrix printer using Crystal Reports. All the add-ons for B1 do this using the crystal report viewer which causes crystal to send true type fonts to the printer, making it very slow. We can run the crystal reports in draft print mode outside of B1, and the performance is good. Is there a way to get the same performance in B1 using Crystal?
    All solutions we have found will require us to launch Crystal reports and have the end user enter parameters, using a link off the application menu works this way. But we are looking for a better solution to print to the dot matrix printer faster.
    Thanks

    Hi Peter,
    When you are printing it from b1 make all the font to the regular type ( not like bold are italic) like that then it will be some how faster...
    Regards
    PL.Chidambaram

Maybe you are looking for