Time  to serialize 10,000 simple objects to a disk file usi

I heard the default serialization routine is slow. So how slow. Let's say I have 10,000 simple objects. How long does it take to serialize them to a disk file using standard Java serialization?
Can anybody give some idea?
Thanks a lot !

The following is my program to test :
import java.io.*;
import java.util.*;
public class Serialization implements Serializable {
public static void main(String[] args) {
     long startTimeInMill = 0 ;
     long endTimeInMill = 0;
          try {
          startTimeInMill = new GregorianCalendar().getTimeInMillis();
               System.out.println("start Mill is " + startTimeInMill);
               FileOutputStream out = new FileOutputStream("theTime");
               ObjectOutputStream s = new ObjectOutputStream(out);
               for (int i = 1; i < 100000; i++) {
                    s.writeObject("Today");
                    Date outputDate = new Date();
                    s.writeObject(outputDate);
                    s.flush();
          } catch (FileNotFoundException e) {
          } catch (IOException e) {
     endTimeInMill = new GregorianCalendar().getTimeInMillis();
     System.out.println("Endtimeinmill is : " + endTimeInMill);
     System.out.println("It takes " + (endTimeInMill - startTimeInMill) + " milliseconds to serialize 10,000 Date objects");
And the following is the result:
start Mill is 1083635995578
Endtimeinmill is : 1083635997937
It takes 2359 milliseconds to serialize 10,000 Date objects
Specs of my hardware: Win2k, CPU 1.8G, DDR RAM: 756 MB

Similar Messages

  • How do I access my encrypted User Account files from my Back Up hard drive?  Time Machine  was used to create the back up disk; File Vault was used to encrypt the files.

    How do I access my encrypted User Account files from my Back Up hard drive?  Time Machine  was used to create the back up disk; File Vault was used to encrypt the files.

    Thanks.  I will try going through TM.  Since my Simpletech is on the way out, I'll be plugging in a new external hard drive (other than the back-up drive) and trying to restore the library to the new drive.  Any advice or warning if this is NOT the right thing to do?
    Meanwhile, that is a great tip to do an alternate back-up using a different means.  It's been tough to figure out how to "preserve access" to digital images and files for posterity, knowing the hardware will always fail/obsolesce sooner or later, and that "clouds" are only as good as their consistent and reliable accessibility.  Upping the odds with redundancy will help dull the edge of my "access anxiety", though logically, it can never relieve it.  Will look into
    Carbon Copy Cloner.

  • Why can't I save a simple object as an ai file?

    All of a sudden, completely out of the blue, I am unable to save even a simple element as an ai file. I'm working in CS3 and just can't figure out what happened. I haven't changed any settings and can't find any documentation on how to solve this problem. Tight deadline. Please help!

    I read through the discussion and can't really see anything that applies.
    I re-installed Illustrator and am getting the same results.
    I opened a new document and drew a plain, one-colour square and tried to save that as an ai file and it gave me the same "an unknown error has occured" when trying to save as an ai file.
    This just doesn't make any sense.
    Everything was working fine yesterday and I've spent the entire day today trying to figure out why it won't do this one simple little task.
    This is the busy time of year and I've no time to waste . . . how despressing, frustrating and discouraging!!!
    Can't ANYONE help?

  • Why no simple method for reading text files

    I'd like to know, after all this time why there is no simple method of reading ext files into a string.
    Yes, yes, I know all about buffered readers, (it took me long enough to figure them out) but they are cumbersome and seem to change every release (how many file methods have been deprecated...)
    Here's what I'm looking for:
    file.open();
    file.read(String);
    file.close();
    No single character at a time, no loop - the whole file into a single string in one shot. If buffers are used, i want it hidden.
    Perl, PHP, VB, C# all have this. Even Java has it when you write to a file.
    So why not on read?
    Yes, buffered streams are very elegant, but for what most programmers want to do, they are overkill and annoying.

    Just Dennis Ritchie's little joke.
    Do you have a better reason for wanting the feature
    other than that some other languages have it?Yes. It would save me time and help dozens of new programmers who continually ask this question in this and other forums. It is in other languages because people use it and want it - clearly Jarkata saw the need. If you don't like the idea, then I won't argue the point. We agree to disagree.
    Also did you have an answer for my question?in java.io.file you can do the following: (i've used it, it works) Granted, you still have to use the buffered output streams, which in my opinion should be abstracted for a simple text read and write.
    BufferedWriter outputStream = new BufferedWriter(new FileWriter(fileNewPath));
    outputStream.write(fileContent);
    outputStream.close();

  • Trying to serialize a simple object

    Hi,
    I can't seem to create an ObjectInputStream. The error is noted in the code below. I also noticd that the output file where I seemingly wrote the object without problems is empty.
    import java.io.*;
    //Class from which an object is serialized:
    class MyClass implements Serializable
         private int num;
         private String str;
         public MyClass(int num, String str)
              this.num = num;
              this.str = str;
         public MyClass()
              num = 0;
              str = null;
         public void show()
              System.out.println(num);
              System.out.println(str);
    public class DemoSerialization
         public static void main(String[] args)
              MyClass A = new MyClass(50, "hello serialization");
              A.show();
    /*Create output file:*****************/
              File myFile = new File("C:\\TestData\\javaIO.txt");
              try
                   myFile.createNewFile();
              catch(IOException exc)
                   System.out.println("couldn't create output file");
                   System.exit(1);
    /*Create output stream:*************/
              ObjectOutputStream out = null;
              FileDescriptor fd = null;     //FileDescriptor represents a connection to a file.  Then,
                                                           //you don't have to do all the file checking, etc, when
                                                           //you move the data in the other direction(see below)
              try
                   FileOutputStream fos = new FileOutputStream(myFile);
                   fd = fos.getFD();
                   out =      new ObjectOutputStream(
                                  new BufferedOutputStream(fos));
              catch(FileNotFoundException exc)
                   System.out.println("couldn't find the file while during creation of file output stream");
                   System.exit(1);
              catch(IOException exc)
                   System.out.println("io error creating output file stream");
    /**/     System.out.println("test1: " + fd); // "java.io.FileDescriptor@df6ccd"
    /*Serialize the object:***************/
              try
                   out.writeObject(A); 
              catch(InvalidClassException exc)
                   System.out.println("class definition of object being written to a file has a problem");
              catch(NotSerializableException exc)
                   System.out.println("class of the object did not implement Serializable");
              catch(IOException exc)
                   System.out.println("general file output error occurred");
    /*Create input file stream:***********/
              FileInputStream fis = new FileInputStream(fd);
              BufferedInputStream bis = new BufferedInputStream(fis);
    /**/     System.out.println("test2: " + bis);  // "java.io.BufferedInputStream@b89838"
              ObjectInputStream in = null;
              try
                   in = new ObjectInputStream(bis);      /*****ERROR--throws exception*****/
              catch(IOException exc     )
                   System.out.println("ObjectInputStream error");
    /**/     System.out.println("test3: " + in);  // "null"
    /*Read in the object:****************/
              MyClass B = null;
              try
                   B = (MyClass) in.readObject();  /***ERROR--NullPointerExecption(see above)***/
              catch(ClassNotFoundException exc)
                   System.out.println("no class definition exists in this program for the object read in");
              catch(InvalidClassException exc)
                   System.out.println("class def is present but there is something wrong with it");
              catch(StreamCorruptedException exc)
                   System.out.println("control info in stream is corrupt");
              catch(OptionalDataException exc)
                   System.out.println("attempted to read in a basic data type--not an object");
              catch(IOException exc)
                   System.out.println("general stream error occurred during read");
              B.show();
    }

    Your originaly source did not include the call to the
    close method of ObjectOutputStream which is why your
    file was created but empty. I assumed you added it
    after the call to writeObject.
    Well, that isn't the case. I posted that I added flush().
    Read the API docs on the FilterDescriptor class.
    This class basically represents an opened file (or
    r other open streams) in either an inputstream OR
    outputstream. So when you close the outputstream.
    The file is not open anymore and thus the
    e FileDescriptor object is no longer valid because it
    represents and open stream.
    I didn't have to read the API docs because to me that seemed like common sense: if I have an object that represents a connection to a file, and I close the connection, it makes sense to me that the object would no longer be valid. Therefore, I didn't use close() in my program.
    As far as avoiding lots of try blocks, why not wrap
    the whole program in a try block? I assume you're
    using all those System.out.println commands to help
    debug. It'd be more helpful if you called
    printStackTrace on the thrown exception when an error
    occurs.
    Ok, thanks.
    I've done some more tests, and the problem isn't specific to serialization. I'm also unable to use a FileDescriptor when reading a char from a file. I get the same "access denied" error:
    import java.io.*;
    class  DemoFileDescriptor
        public static void main(String[] args)
            //Create a file:
            File myfile = new File("C:\\TestData\\javaIO.txt");
            try
                myfile.createNewFile(); 
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("io exception createNewFile()");
            //Create a FileInputStream:
            FileOutputStream out = null;
            try
                out = new FileOutputStream(myfile);
            catch(FileNotFoundException exc)
                System.out.println(exc);
                System.out.println("error creating FileOutputStream");
            //Get the FileDescriptor:
            FileDescriptor fd = null;
            try
                fd = out.getFD(); //a file connection
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("trouble getting FileDescriptor");
            //Output something to the file:
            char ch = 'a';
            try
                out.write((int) ch);
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("io error writing to file");
            //Create a FileInputStream using the FileDescriptor:
            FileInputStream in = new FileInputStream(fd);
            //Read back from the file:
            char input = ' ';
            try
                input = (char) in.read();  /**ERROR-access denied**/
            catch(IOException exc)
                System.out.println(exc);
                System.out.println("problem reading");
                exc.printStackTrace();
            System.out.println(input);
    } Here is the output and stack trace:
    ---------- java ----------
    java.io.IOException: Access is denied
    problem reading
    java.io.IOException: Access is denied
         at java.io.FileInputStream.read(Native Method)
         at DemoFileDescriptor.main(DemoFileDescriptor.java:69)
    Output completed (2 sec consumed) - Normal Termination

  • Concurrent timers are not getting invoked for same timer info (Serializable

    Problem Scope: Concurrent timers are not getting invoked for same timer info (Serializable object containing the details of timer).
    Details : I am implementing EJB timer 2.1 and when ejbTimeOut execution of one timer exceeds the interval time, next timeout doesn’t happens till the execution of first ejbTimeOut completes . Ideally the timers should behave in the manner that on every interval the ejbTimeOut should occur no matter the previous timeout is completed or not
    for example : consider there is timer T whose timeout occurs every minute, and on every timeout it calls process P, so on every minute ideally container should give call to process P irrespective of the previous status of P (call is complete or not). In our case next call to process P is not happening after timeout also since it is waiting for previous call to P to get completed

    You should also cross-post this in the WebLogic EJB forum:
    WebLogic Server - EJB

  • Locking Bol entity in Simple object

    Hi,
    I have created a Simple Object with a structure and have assigned the BOL entity to my custom view. Now if I want to lock the structure in event handing method, the locking fails. how can I lock the custom structure?
    Thanks,
    Nandini

    Dear Chicon,
    I made thread to sleep for checking the "Object Locking" functionality of OpenJPAEntityManager. My intention was to block the second thread when the first thread being locked when a concurrent access occurs. But it doesn't happened and code execution passed to thread sleep.
    I mean when 2 client access the same entity at same time (in same milliseconds) , and what happens to 2nd thread when 1st thread locks the entity object.
    I guarantee you that i started the 2nd thread before the 4sec time stamp given to the object locking. I tested it with a bigger timestamp, still it given concurrent blocking of the same entity bean.
    My question is why the object locking is not working with concurrent access to same entity bean from more than one thread???
    I think you get the correct question what i intended ????
    Regards,
    Raj...

  • Run-time error '1004' -- Method 'Container' of object '_Workbook' failed

    Dear All,
    One of our users is getting the following Microsoft Visual Basic error while running the report S_ALR_87013614.
    Run-time error '1004'
    Method 'Container' of object '_Workbook' failed.
    I have searched the forum posts for help. But I only found some details related to Run-time error 1004 related to some excel file security but not related to "Method 'Container' of object '_Workbook' failed".
    Could anyone please tell me how this error can be eliminated for the user?
    Regards,
    Lakshmi.

    Dear Arpan,
    We too observed a few PIDs along with the one that you have mentioned but they make no difference. Some users who has the PID G_RW_DOCUMENT_TYPE set with some value are getting the report.
    Upon further searching we are assuming that it could be an issue with the Microsoft applications or macro settings of the user. But not sure about it.
    Regards,
    Lakshmi Venigala.

  • Run-time error '1004' Application-Defined or object-defined error

    Hello friends,
    My requirement is to make the cells under Columns Actual, forecast and target (Dimesnion Category) Locked.
    I've used various methods like GetOnlyRange but it didnt work.
    Now, i've selected all the cells of the sheet, where user can input and made them unlocked. ( from Right-click>FormatCells>Protection tab-->Locked checkbox unchecked)
    Then, go to "review" tab, click "Allow Users to edit Ranges",-> Protect Sheet---> ticked "Unlocked Cells"
    Then go to WorkBook Options and set a password for the worksheet.
    But on expand, I'm facing Run-time error '1004' Application-Defined or object-defined error.
    Please help.
    Please help.

    Hi,
    I think that  is VBA Runtime error, you can fix these errors by downloading in various sites.
    http://www.articlesbase.com/data-recovery-articles/vba-runtime-error-1004-application-defined-or-object-defined-error-fix-these-errors--1339060.html
    You can try with the above link.  I hope this could solve your problem.
    Regards,
    B.S.RAGHU

  • To reinstall Acrobat 8 Upgrade I need to present previous versions e.g. 3 and then 4 and then 5 Upgrade every time. Is there no simpler way to validate my ownership?

    To reinstall Acrobat 8 Upgrade I need to present previous versions e.g. 3 and then 4 and then 5 Upgrade every time. Is there no simpler way to validate my ownership?
    I had two laptops stolen and the reinstall is a real pain. This also applies to reformats and changeovers to Windows 7, etcetera.

    Windows 7? Then don't waste your life minutes fumbling with an Acrobat 8 - Windows 7 combination.
    If you are to be using Win 7 you'll need the current release of Acrobat (XI). "X" will function but it is no longer marketed by Adobe.
    Be well...

  • How to  Serialize a very big Object??

    Please help me !

    I misread that as sterilize for a moment. Buckets and buckets of dettol! And that's the clean answer.
    As Athena indicates you Serialize a very big Object in exactly the same way that you Serialize a very small object.
    Are you encountering a problem, and if so what is it?
    Dave.

  • Run-time error -2147417848 (80010108), method '~' of object '~' failed

    Hello
    I have an application written in VB6 which uses Crystal 9 Reports (RDC). The application is running on Windows XP, SP2.
    On this PC is .net Framework 2.0 installed and since then from time to time I get the message:
    run-time error -2147417848 (80010108), method '' of object '' failed
    But this error doesn't appear always, but when it happens, it happens always at setting the datasource
    example:
    repReport.Database.SetDataSource rsDummy
    Does anybody know why this is?
    Thank you for your help.

    Hi, Urs;
    Whereever the error is occuring, you should ensure you have the latest version of our files. For a client install, be sure that you are using the latest Merge Modules from our web site to deploy your application.
    If you are not getting the error on your development system, you may have newer files there than on the client.
    Regards,
    Jonathan

  • Why does Muse crash practically every time I go to place an object?

    Why does Muse crash practically every time I go to place an object?

    Hello Zak. I am using Adobe Muse CC latest version on an iMac 7 running Yosemite version 10.
    I am placing a .jpg photo onto a page at the same size. Sized to fit I mean. This is happening about every 3 to 4 times I do something like asking to Place a file. It is driving be mad.
    I attach a screen grab of this all too familiar screen. I have updated to Air 3 also. What is going on, please help.
    Thanks.
    With kind regards, Richard
    Because good design is everyone's business.
    ROC Design Killough House, Killough Lower, Kilmacanogue, Bray, Co Wicklow.
    Call: 01 2762118 Email: [email protected] Skype: killoughhouse
    Web: http://www.rocdesign.ie

  • Effect from build time dependent  2 attribute in info object master data

    Dear all,
    i creat time dependent  2 attributes in info object master data (ZCURRLUM) which use in info cube. after that i open workbook or query, it has short dump which error message
       "UNCAUGHT_EXCEPTION" "CX_RSR_X_MESSAGE"
       "CL_RSBOLAP_BICS_SERVICES======CP" or "CL_RSBOLAP_BICS_SERVICES======CM003"
       "HANDLE_UNCAUGHT_EXCEPTION"
    Question: info object master data can't use more than a attribute time dependent???
    i use in BI 7.0 level 14
    thanks for your help
    regards,
    Joy

    Hi Chandamita Sarmah,
    I copy error code to you from line 1 to line 28
    METHOD handle_uncaught_exception.
      data:
        l_r_program_error  TYPE REF TO cx_rsbolap_program_error.
      data: lBExDebug type rs_bool.
      GET PARAMETER ID 'BEXDEBUG' FIELD lBExDebug.
      if lBExDebug = rs_c_true or CL_RSTT_TRACE=>GET_TRACEMODE_CURRENT_TRACE( ) = rstt0_c_tracem
    Break-point for debugging, e.g. during running a trace
        break-point.  "#EC NOBREAK
      endif.
    Subcall?
      if P_RFC_CALL_DEPTH > 1.
      Forward the exception
        subtract 1 from P_RFC_CALL_DEPTH.
        DATA: l_r_x TYPE REF TO cx_no_check.
        TRY.
           l_r_x ?= i_r_exception.
          CATCH cx_root.
            CLEAR l_r_x.
        ENDTRY.
        IF l_r_x IS INITIAL.
          RAISE EXCEPTION TYPE cx_rsr_propagate_x
            EXPORTING
              previous = i_r_exception.
        ELSE.
        RAISE EXCEPTION l_r_x.
        ENDIF.
      endif.
    All exceptions should have been caugth -> X-Message
    Thanks a lot for your help
    Joy

  • What time Oracle Spatial Can support text object

    Hi:
    I want know what time oracle spatial can support text object. it is very useful for
    GIS and LBS customer.
    null

    Hi,
    I think it is an interesting idea, but there are difficulties when implementing such objects in the database level. For one thing, the placement, orientation of text for a point geometry is often dependent on point geometries stored in other rows in order to acheive an optimal and non-overlapping placement. It also depends on the font and size of the text, as well as the scale and level of detail when visualizing the spatial data. Such contextual information is only available to an application. I hope I understood you correctly and if you have further comments I would like to hear them too.

Maybe you are looking for

  • How to scan a document as a PDF file

    Please provide me with advice/expertise on the procedure to follow and if purchase of software is required. (I'm obviously a rookey !)

  • Initial value in transformation

    In 3.5 update rules there was an option of setting the value as initial value.  How can I do this in a BI 7 transformation? Thanks

  • Performance Appraisal - Transports

    Hello Experts! I am wondering about best practices involved in building performance appraisals.  I know that you can use a transport function for performance appraisals, however it does not really work well for me.  When I attach Category Groups (VB)

  • Hyper V what to do to maintain?

    Hello everybody We sold an HyperV Cluster to one of our customers it was a promotion from HP. The customer got a 2 node cluster with a HP  MSA on this we installed Windows Server 2008R2 and installed the Hyper V role. On this there are several virtua

  • Heading and color scheme of the columns for the detail report

    Is it possible to have a heading and color scheme of the columns for the reports displayed on drill down of a query in WAD?