Client-side resource calculation for project amount screen

Threads moved from the Suggestions forum after implementation

Moderators: Public Relations Department, Players Department

User avatar
joo
Posts: 5021
Joined: Fri Jun 17, 2005 2:26 pm
Location: London, UK

Client-side resource calculation for project amount screen

Postby joo » Tue Jan 22, 2008 3:30 pm

Like so...

This would cut down the amount of time spent calculating the amounts myself based on the per-day figures given. If you wanted to go the whole hog you could make all the fields editable, including the number of hours spent on the project to allow total control - this method would still be completely secure as one value would still only be sent to server where the final calcuations can be made. It would only make it more convenient for the user :)
User avatar
SekoETC
Posts: 15523
Joined: Wed May 05, 2004 11:07 am
Location: Finland
Contact:

Postby SekoETC » Tue Jan 22, 2008 3:49 pm

Cool, very cool! Everybody talks about adding stuff like this but no one actually bothered to write the code. It should tell the user to click outside the box to make the numbers to appear but other than that it's cool. You give it the same info as before so there's no need to change the server-side script. The only difference is that people have no need to start over and cancel projects several times to test and fix amounts.
Not-so-sad panda
User avatar
Doug R.
Posts: 14857
Joined: Wed Mar 23, 2005 6:56 pm
Contact:

Postby Doug R. » Tue Jan 22, 2008 4:14 pm

I like it in principle, but giving the server more work is definitely not something we need right now.
Hamsters is nice. ~Kaylee, Firefly
User avatar
Chris
Posts: 855
Joined: Sat May 05, 2007 1:03 pm

Postby Chris » Tue Jan 22, 2008 4:32 pm

Doug R. wrote:I like it in principle, but giving the server more work is definitely not something we need right now.

The calculations are done client-side. The only increase for the server is that the page it sends out is (trivially) longer by a couple of Javascript lines.
User avatar
Doug R.
Posts: 14857
Joined: Wed Mar 23, 2005 6:56 pm
Contact:

Postby Doug R. » Tue Jan 22, 2008 5:20 pm

Chris wrote:
Doug R. wrote:I like it in principle, but giving the server more work is definitely not something we need right now.

The calculations are done client-side. The only increase for the server is that the page it sends out is (trivially) longer by a couple of Javascript lines.


Sorry if I'm being dense, but is it really trivial? 3/4 of the lag seems to be outputting the page back to the player. I hit submit, the info is sent reasonably fast, and then I wait 5 mins or longer for the page to refresh. Even if it slows things by 1% on a 5 min lag, that's 3 extra seconds on a process that should be instantaneous.
Hamsters is nice. ~Kaylee, Firefly
User avatar
joo
Posts: 5021
Joined: Fri Jun 17, 2005 2:26 pm
Location: London, UK

Postby joo » Tue Jan 22, 2008 5:50 pm

HTML pages can be compacted to eliminate white space and unneccesary comments, lines of code etc. I could definitely reduce the code I used to about two or three lines.

BTW I changed it so the field is updated periodically (any changes would be seen within a second)
User avatar
joo
Posts: 5021
Joined: Fri Jun 17, 2005 2:26 pm
Location: London, UK

Postby joo » Tue Jan 22, 2008 5:53 pm

Actually, If most of the lag is caused by sending users the same pages over and over again with different data displayed on them, wouldn't it be more efficient to use some sort of XML and CCS/Javascript combination rather than having the server compose the HTML?

This would probably be a long term change, but it's just an idea...
User avatar
SekoETC
Posts: 15523
Joined: Wed May 05, 2004 11:07 am
Location: Finland
Contact:

Postby SekoETC » Tue Jan 22, 2008 6:15 pm

Usually sending text to the users isn't what's heavy, sending queries to a database is what. For all we know, the lag might be caused by the fact that more things have been made translatable, thus increasing the number of things that need to be fetched from the database, and the amount of languages has also been increasing. But anyway, the JavaScript code wouldn't have to be fetched from any database since it's the same for everyone, only the output would vary.
Not-so-sad panda
User avatar
Chris
Posts: 855
Joined: Sat May 05, 2007 1:03 pm

Postby Chris » Tue Jan 22, 2008 6:30 pm

I thought that the one and only cause of major lag was processing time-related things (projects, travel, animal activity, rot). 100 users can be on, and I'll get pages in under one second if a task isn't being processed.
User avatar
Doug R.
Posts: 14857
Joined: Wed Mar 23, 2005 6:56 pm
Contact:

Postby Doug R. » Tue Jan 22, 2008 9:41 pm

That's true Chris, but heavy users + some processes = tremendous lag. The two don't mix. See this thread(http://www.cantr.net/forum/viewtopic.php?t=14428) which attempts to track down the lag causes.
Hamsters is nice. ~Kaylee, Firefly
User avatar
marol
Posts: 3728
Joined: Sun Jul 17, 2005 11:45 am
Location: Kraków, PL
Contact:

Postby marol » Wed Jan 23, 2008 12:29 am

:arrow: Moved to accepted suggestion.

Currently performance bottleneck of Cantr is MySQL database. PHP is not an issue. This implementation would involve PHP and it was already been considered by myself, though programmers job queue is quite long recently.
(SRVPRC)
Image
User avatar
Torkess_theCommie
Posts: 499
Joined: Mon Apr 03, 2006 3:44 am
Location: British Columbia, Canada

Postby Torkess_theCommie » Wed Jan 23, 2008 12:54 am

ah cool :D

Reminds me of moles and stoichiometry...
Image
DELGRAD
Posts: 411
Joined: Thu Apr 27, 2006 4:38 am

Postby DELGRAD » Wed Jan 23, 2008 7:13 am

Really nice Joo. Keep that up.

Thankyou Seko/database , marol/MySQL.
I have next to nothing by way of any programming, but you only need to watch the database time compared to total time to know that the database is the lag bringer.
Everyone needs to remember, many people with many characters and a whole shitload of objects and activities tied to each will inevitably bring lag.
Science teacher: "good morning class"
students groan
Science teacher: "Today we will be learning about intelligent design"
Little Billy: "OH GOD"

First quoted in the NationStates forum on 10/14/05.

http://washingtonvil.myminicity.com
User avatar
UloDeTero
Posts: 344
Joined: Thu Dec 01, 2005 3:03 pm
Location: Cheshire, England

Postby UloDeTero » Wed Jan 23, 2008 4:12 pm

Not to steal your thunder, joo, but I did something similar recently. That too could use client-side calculations. In fact, I had that in mind but didn't mention it in the post at the time.
User avatar
joo
Posts: 5021
Joined: Fri Jun 17, 2005 2:26 pm
Location: London, UK

Postby joo » Wed Jan 23, 2008 5:54 pm

Ah yes, but people just naturally listen to me, you see. That's what makes me such a great dictator :lol:

Return to “Implemented Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest