Jump to content

vintox

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by vintox

  1. Hi Andy123, the last 2 examples works and do the job but the consume a lot of memory and processing time. foreach is a better way to work with arrays. but with foreach is like it checks if its the end of the array before it executes the code inside
  2. $views++ first place the value inside the string after that it increments it. do it like this: ++$views or $nViews = $views++ "UPDATE page_views2 SET views = $nViews WHERE institute_id = $institute_id";
  3. i have a foreach statement which looks like this foreach(static::$_components as &$field){ ..some code } in "some code" i sometimes add more components to "static::$_components" member if the insertion happens not at the final iteration it works, and the foreach detect & use the last insertion. but if the insertion happens at the last iteration the foreach statement breaks(ends) without detecting & using the last insertion there is any workaround for this issue beside using for loops and count(array). i prefer using foreach due to performance demands for($iterator = 0, $field = ''; null != ($field = empty(static::$_components[$iterator]) ? null : static::$_components[$iterator]); $iterator++){ ...some code } consumes a lot of memory and proccessing time using for($iterator = 0; $iterator < count(static::$_components); $iterator++){ ...some code } is even worse Thanks in advance
  4. ok, Thanks Kicken
  5. the assigning occurs at the controller. after the assigning i am executing View::render($data); there i am doing extract. the second method skips the assigning to a variable and the extracting by the view class and execute the pageFooter method so logically it should use less memory you mentioned the different times i am executing pageFooter. if i use memory_get_peak_usage() is it still matter?
  6. using memory_get_peak_usage() gives the same results as memory_get_usage when i use "pageFooter" method. returns 108kb if i use memory_get_usage(true)/memory_get_peak_usage(true) i get 256kb even if i add code to my script still returns 256kb
  7. I am developing a system using the MVC design pattern. for debugging & optimizing the script i am using memory_get_usage() at the Start and the End of the script. i have a file footer.html.php if the file looks like this <?= $bodyContent ?> by using extract with $bodyContent = \Views\General_View::pageFooter(); the script consume 76kb of memory. but if i change footer.html.php to <?= \Views\General_View::pageFooter() ?> the script consume 108kb of memory. pageFooter method is: static public function pageFooter() { $str = '<br /><br />'.Converter::memorySizeConverter($b = memory_get_usage()). ' ('.Converter::memorySizeConverter($b-SCRIPT_START_MEMORY).')'; $end = microtime(true); $str .= '<br />Processing time: '. sprintf('%.4f', ($end-SCRIPT_START_TIME)).' seconds'; return $str; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.