cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebastien Chauffray (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-12019) cordova-plugin-file : Performance issue between version 3.0.0 and 4.3.0
Date Thu, 20 Oct 2016 07:17:58 GMT

    [ https://issues.apache.org/jira/browse/CB-12019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15591052#comment-15591052
] 

Sebastien Chauffray commented on CB-12019:
------------------------------------------

I'll try to describe the process we use, hope it could help.
Do not hesitate to contact me if you need more informations or if you see something wrong...

Info: 
Same code is used for both plugin versions.
We use WinJS librairy to manage some stuff like Promise.
ctrl.largeFileTemplate is a large stringify Json about 4 000 characters.


Function 1 - Used to create a file : 
         createFile: function (filePath, textContent) {
                var ctrl = this;
                return new WinJS.Promise(
                    function (completeDispatch, errorDispatch, progressDispatch) {
                        //Delete the file first
                        ctrl.deleteFile(filePath).then(
                            function (res) {
                                //Create the file and write the content
                                ctrl._dataDirectoryEntry.getFile(filePath, { create: true
}, function (fileEntry) {
                                    fileEntry.createWriter(function (fileWriter) {
                                        fileWriter.onwriteend = function (evt) {
                                            completeDispatch(true);
                                        };
                                        fileWriter.onerror = function (err) {
                                            //Some STUFF
                                            errorDispatch(err);
                                        };
                                        fileWriter.write(textContent);
                                    });
                                });
                            }, function (err) {
                                  //Some STUFF
                                  errorDispatch(err);
                            });
                    });
            }


Function 2 : Used to run some function recursively
           _recursively: function (array, fct, i) {
                var ctrl = this;
                i = i || 0;
                if (i < array.length) {
                    return fct(array[i]).then(function () {
                        return ctrl._recursively(array, fct, ++i);
                    });
                } else { return WinJS.Promise.wrap(); }
            }


Main test function : Create files recursively
      createFilesSynchon: function () {
            var ctrl = this;
            var nbFiles = 1000;
            //Generate an array with integer from 1 to nbFiles
            var myarray = Array.apply(null, { length: nbFiles }).map(Number.call, Number);

            //use _recursively function to call the creation of one file
            ServicesT.MiSyncService._recursively(myarray, function (i) {
                //create the file
                var filepath = ServicesT.IOService.formatURL(ServicesT.IOService.getSubFolderDataPathIN()
+ '\\createFilesSynchon_' + i + '.json');
                return ServicesT.IOService.createFile(filepath, ctrl.largeFileTemplate);
            });
        }


> cordova-plugin-file : Performance issue between version 3.0.0 and 4.3.0
> -----------------------------------------------------------------------
>
>                 Key: CB-12019
>                 URL: https://issues.apache.org/jira/browse/CB-12019
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File
>    Affects Versions: 3.5.0
>         Environment: Tests done with Visual Studio 2015, cordova cli 6.3
> Materiel : Samsung A5 2016, Android 6.0.1
>            Reporter: Sebastien Chauffray
>            Priority: Minor
>              Labels: performance
>
> Performance tests to compare cordova-plugin-file 3.0.0 to 4.3.0
> I've done 3 tests : 
> Test 1 : Create 1 000 files (about 4 000 characters each) in synchronous mode. I wait
the end of a file to create the next
> Test 2 : Create 500 files (about 4 000 characters each) in asynchronous mode. Don't wait
to create all the file
> Test 3 : Create a file by 400 appends of 4 000 caractères and read this file (about
1.60 Mo)
> I mesure each test and see very bad performance for version 4.3.0 of the plugin...
> You can see the result in the array : 
> Version	3.0.0	
> 	          Cycle 1	                 Cycle 2
> Test 1	21s 975ms	        22s 78ms
> Test 2	4s 118ms	                 3s 761ms
> Test 3	10s 317ms	
> Version	4.3.0	
> 	          Cycle 1	                 Cycle 2
> Test 1	50s 341ms	        51s 10ms
> Test 2	8s 172ms	                 9s 230ms
> Test 3	16s 484ms	
> if needed, i can discuss about the test detail



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message