I'm developing a PhoneGap application using jQuery Mobile and KnockoutJs. I've a collection that can grow upto 500. I've set the collection as observable and also all the properties (max 4) of each object in the collection as observables. Will this affect the performance of the application?
Create a test case and time it. That's the only reliable way to answer performance questions.
Related
I'm using an sqlite db to populate an ios app with data about irregular verbs -- it's a language learning app.
The db has 3 tables, verb categories, verbs, and verb elements. The last has one entry per verb termination, so 50-odd per verb. The total db is about 2,500 entries, each one has 3-5 short string fields.
My question is whether the best thing to do from a performance point of view is:
(1) - write structs to model the data, each with appropriate functions, and load the db into memory in the form of structs when the app initialises, OR
(2) - write functions to query the sqlite db on the fly for each new view
My guess is that (1) is much better for a small db of this size, but I thought I would consult your collective wisdom as I'm a novice. Thanks in advance for any advice.
Btw, this is a follow up question to one I asked about how to get data into an ios app:
What's the best practice for storing and importing (non-user) data for an iOS app in swift/swiftUI/Xcode?
Both solutions should be sufficient for your case.
When it comes to performance this is question on what you are measuring.
Quick loading time
Quick operations in background
Smooth user interface and interactions
Energy consumtions
Memory consumptions
...
For instance when increasing memory consumption you have to understand that your app will more likely be terminated when in background. If user decides to take off 5 minutes and opens a game which loads immense amount of memory your application will more likely be terminated to get that memory for another application.
But again. Both solutions should be fine for the size you are describing here. Over time if this increases you may need to reconsider.
Also there is an option 3 where you can just hardcode these values directly into structures so you even lose initial load time. Just make a script or something that transforms your files with strings to source code.
Have you thought about CoreData? I use it for a small DB and it works fine. There is of course the learning curve of CoreData, but once you get over that, it does a lot of the work for you and has some integrations with SwiftUI as well. I am not saying it is more or less performant in any way, just that once over the learning curve, it is pretty easy to use and of course optimized by the Apple CoreData team.
I am using dev express grid in MVC application, it works fine. But when I change page size=500 in pagination then grid view loading performance has been decreased.Can you suggest me how to resolve this problem?
Thanks in advance.....
To increase the performance you can reduce the amount of data (per row) in your model if the bottleneck is the data transfer between the server and client. You can do this by creating a 'slimmed down' view model containing only essential data.
If however it's a database call that's taking a long time perhaps you need to look at your ORM code to understand what's taking so long.
I'm wondering about the performance differences between two different methods of data filtering. Here's what I'm working with:
A set of core data objects
A UISegmentedControl that represents a boolean filter (learned vs. not learned)
A UITableView that displays the filtered data set
As I see it, there are two possible approaches here:
Pull the entire core data set in viewDidLoad. Filter the array of data using a predicate when the segmented control value changes. Reload the tableview.
Initially pull the core data set with a predicate. When the segmented control value changes, re-pull the core data set with the updated predicate. Reload the tableview.
I know there are factors that influence the answer (how large the data set is, how often the segmented control will be used), I'm just wondering if there is an overall best practice between the two.
There are trade-offs between the two approaches, and the best choice depends on how important the differences are to you. No one approach is the best practice for every situation.
Loading everything up front in one array will likely have:
Slower startup time (because of doing a large fetch right off)
Higher memory use (since you're fetching everything rather than just a subset)
Faster when switching between filter options (since you already have the data)
Doing a new fetch every time will likely have:
Faster startup time
Lower memory use (since you only ever have a subset of the total collection)
Slower when switching between filter options, at least at first (Core Data's internal row cache will speed things up on subsequent switches).
How significant the factors are depends on your data and your app. If you have lots of data, then the memory use may be significant (fetching every instance of an entity type is an easy way to blow out your memory use). Speed concerns depend on what else your app is doing at the same time and, frankly, on whether either option is slow enough to cause a noticeable delay. If your data set is small, it probably doesn't make much difference which approach you use.
I don't expect there will be any user-noticeable speed difference.
Therefore these are best practices that I think are relevant here:
Avoid premature optimization.
You're constrained by memory more often than speed.
Design in advance.
From this I deduce three points of advice that apply to current problem:
Go with the method that is easiest to maintain.
Don't pull more objects from Core Data than necessary.
Have some strategy about updating the data in the tableview.
To combine those points in one advice, it's best to use the class NSFetchedResultsController for displaying Core Data in tables as it's specifically designed for this purpose:
Encapsulates the idea of "the chunk of data I'm currently displaying".
Saves you memory by not pulling things you don't need.
Helps with updating data in tableview.
You can play with examples of it by creating a new Core Data-based project in Xcode (4.4 or later). It's closer to the second of your approaches.
I need solution to display XML data tree (stored as plist) via UITableview on iOS
It's desirable to have:
ability to display XML data tree in nested tables
ability to re-arrange nodes in XML tree using WYSIWYG principle
ability to add new nodes and copy-paste existing
Any ready-to-use snippets/libraries?
Is there a reason why you'd want to use nested tables rather than a single table with indented rows? The single table approach should be much easier to set up and manage.
TLIndexPathTools has a great example of a hierarchical table with expandable levels. Try running the Outline sample project. TLIndexPathTools is a low-level library, so it should be easy to modify to your specific needs.
UPDATE: given solution doesn't work with iOS7 and greater
Did not found good solution nowhere, so made it by myself.
It uses nested UITableView in recursive mode.
Features:
displaying of XML data tree of any depth
supports custom sizes, rotation and both iPad/iPhone screens
supports re-arranging (move node up, move node down, delete, copy-paste, create new)
https://github.com/braginets/NestedTablesForXMLDataTree
NB: I am aware that this solution maybe not perfect, it's rather an attempt to make my modest input into this great community to thank for all for their knowledge sharing.
According to Brad Wilson, RenderAction is slower than RenderPartial.
However, has anyone got any statistics that show the difference in performance?
I'm in the process of developing an application where pages are composed of "Widgets".
I have two choices:
Composition at the View Level
Call RenderAction for each widget. This is by far the easiest approach but does mean that we're performing a full MVC cycle for each widget.
Composition at the Controller Level
Compose one ViewModel for the page that contains the data we need for each widget. Call RenderPartial for each widget. This is much more complicated to implement but does mean we'll make only one MVC cycle.
I tested the above approaches with 3 different widgets on a page and the difference in render time was 10ths of a second (hardly worth worrying about).
However, has anyone got any test results more concrete than this, or perhaps experience trying both approaches?
I've recently worked on an application that was experiencing performance issues, and found a view that was making four calls to RenderAction, plus another one in the layout. I found that each call to RenderAction--even when I added in a dummy action that returned an empty view--took around 200-300ms (on my local machine). Multiply by the number of calls and you have a huge performance hit on the page. In my case there were four calls causing about a second of unecessary server-side overhead. By comparison, calls to RenderPartial were around the area of 0-10ms.
I would avoid using RenderAction wherever possible in favor of RenderPartial. The controller should be responsible for returning all necessary information. In the case of widgets, if you need multiple actions for several widgets, I would try composing them into one action so the RenderAction overhead only occurs once, though if your site performs adequately I'd keep them separate for a cleaner design.
Edit: I gathered this information using MiniProfiler and hitting the site. It isn't super accurate but it does clearly show the differences.
Edit: As Oskar pointed out below, the application in question likely had some intensive code that runs for each request in global.asax. The magnitude of this hit will depend on the application code, but RenderPartial will avoid executing another MVC cycle altogether.
I'd suggest 2 more options, both require to compose the view model at Controller level and both can work together (depending on the data)
Html.DisplayFor() - display templates
Helpers via extension methods
Option 2 works very well if you want to keep those widgets in different assemblies, after all they're just functions returning a string. I think it has also the best performance, but of course you lose the 'designer friendly' templates. I think it's important to consider the maintainability aspect, not only raw performance (until you really need it, and even then, caching is more helpful).
For small stuff (date or name formatting etc) i'd use helpers, since the html is usually a span with a class, for more complex stuff I'd use the display templates.