Hello
I have a script that must run as fast as possible , This script is about 50 lines
This script have 4 parts
1- get inputs and validates , take about [color="#2E8B57"]1 Microsecond[/color]
2- authenticates , take about [color="#FF0000"]1 second[/color]
3- sending download file , take time depend on file size but not important it is about [color="#2E8B57"]5 milliseconds[/color] usually
4- log usages , take about [color="#FFA500"]0.1 second[/color] (it is just new model , initialization and model->save())
"Part 2" or "authenticates" is about 8 lines , 7 lines take about [color="#2E8B57"]10 Microseconds[/color] but 1 line take about [color="#FF0000"]1 seconds[/color]
that means 49 lines take about [color="#FFA500"]0.1 second[/color] and 1 line take [color="#FF0000"]1 second[/color]
1 second is very large for this script because this script must run by many user (about 10,000 user) and each user run this script 100-1000 times/day
The line that take [color="#FF0000"]1 second[/color] is :
$service = Service::model()->find($criteria);
and $criteria is
$criteria = new CDbCriteria;
$criteria->compare('LOWER(t.username)', strtolower($username));
$criteria->compare('LOWER(t.password)', strtolower($password));
$criteria->compare('t.enable', 1);
1- [size="5"]How can I improve this script to run faster ??[/size]
2- Usually how long Yii ActiveRecord 's [color="#FF0000"]find()[/color] method takes ?
2- Usually how long Yii ActiveRecord 's [color="#FFA500"]save()[/color] method takes ?