optimizing code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andreas Paasch

    optimizing code


    I've finally gotten my nice little system working and it's gone live.
    Now, I spent time optimizing my code and adding a little smart functionality
    here and there, based on needs and simplicity.

    In this context, I was wondering about something.

    I have a growing include.inc file that holds all my functions in it.

    Thinking speed, I was thinking that it might be a bit faster to split that
    include.inc file up into the different functions and then only include_once
    those that actually are needed by the different pages.
    But without any reference and in-depth knowledge, I don't know if this is a
    win situation or loose, in matters of time.

    I'm running Mandrake 9.2 here on a 2.4 kernel but was at the same time
    considering to upgrade to 2.6 kernel, once it seems to be solid enough.
    According to the NG Mandrake 2.6 kernel still has a very few issues that I'd
    like to avoid.

    But considering optimization and time, would it be most practical and faster
    to split my functions or keep it as is?

    /Andreas
    --
    Registeret Linux user #292411
  • Jochen Daum

    #2
    Re: optimizing code

    Hi Andreas!

    On Sun, 15 Feb 2004 13:24:30 +0100, Andreas Paasch
    <Andreas@Paasch .Net> wrote:
    [color=blue]
    >
    >I've finally gotten my nice little system working and it's gone live.
    >Now, I spent time optimizing my code and adding a little smart functionality
    >here and there, based on needs and simplicity.
    >
    >In this context, I was wondering about something.
    >
    >I have a growing include.inc file that holds all my functions in it.
    >
    >Thinking speed, I was thinking that it might be a bit faster to split that
    >include.inc file up into the different functions and then only include_once
    >those that actually are needed by the different pages.
    >But without any reference and in-depth knowledge, I don't know if this is a
    >win situation or loose, in matters of time.
    >
    >I'm running Mandrake 9.2 here on a 2.4 kernel but was at the same time
    >considering to upgrade to 2.6 kernel, once it seems to be solid enough.
    >According to the NG Mandrake 2.6 kernel still has a very few issues that I'd
    >like to avoid.
    >
    >But considering optimization and time, would it be most practical and faster
    >to split my functions or keep it as is?[/color]

    I have measured this for several thousand lines of array declarations,
    and it is faster than most short loops, that I run. Its not worth
    optimising, only optimise the slowest code.

    HTH, Jochen
    --
    Jochen Daum - Cabletalk Group Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • CountScubula

      #3
      Re: optimizing code


      Just a suggestion, it the difference is slight, and you have few vistitors
      (less than 1000 day) you might just want to leave ti as is for simplicity.

      --
      Mike Bradley
      http://www.gzentools.com -- free online php tools
      "Andreas Paasch" <Andreas@Paasch .Net> wrote in message
      news:dvJXb.9105 0$jf4.5681483@n ews000.worldonl ine.dk...[color=blue]
      >
      > I've finally gotten my nice little system working and it's gone live.
      > Now, I spent time optimizing my code and adding a little smart[/color]
      functionality[color=blue]
      > here and there, based on needs and simplicity.
      >
      > In this context, I was wondering about something.
      >
      > I have a growing include.inc file that holds all my functions in it.
      >
      > Thinking speed, I was thinking that it might be a bit faster to split that
      > include.inc file up into the different functions and then only[/color]
      include_once[color=blue]
      > those that actually are needed by the different pages.
      > But without any reference and in-depth knowledge, I don't know if this is[/color]
      a[color=blue]
      > win situation or loose, in matters of time.
      >
      > I'm running Mandrake 9.2 here on a 2.4 kernel but was at the same time
      > considering to upgrade to 2.6 kernel, once it seems to be solid enough.
      > According to the NG Mandrake 2.6 kernel still has a very few issues that[/color]
      I'd[color=blue]
      > like to avoid.
      >
      > But considering optimization and time, would it be most practical and[/color]
      faster[color=blue]
      > to split my functions or keep it as is?
      >
      > /Andreas
      > --
      > Registeret Linux user #292411[/color]


      Comment

      • Andreas Paasch

        #4
        Re: optimizing code

        CountScubula wrote:
        [color=blue]
        >
        > Just a suggestion, it the difference is slight, and you have few vistitors
        > (less than 1000 day) you might just want to leave ti as is for simplicity.
        >
        > --
        > Mike Bradley
        > http://www.gzentools.com -- free online php tools[/color]

        [snip]

        Thanks, I'll leave it as it is then ...

        /Andreas
        --
        Registeret Linux user #292411

        Comment

        • Andreas Paasch

          #5
          Re: optimizing code

          Jochen Daum wrote:
          [color=blue]
          > Hi Andreas!
          >[/color]

          [snip]
          [color=blue]
          > I have measured this for several thousand lines of array declarations,
          > and it is faster than most short loops, that I run. Its not worth
          > optimising, only optimise the slowest code.
          >
          > HTH, Jochen[/color]

          Thanks, I'll leave it as it is :-)

          --
          Registeret Linux user #292411

          Comment

          • David Mackenzie

            #6
            Re: optimizing code

            On Mon, 16 Feb 2004 08:39:31 +1300, Jochen Daum
            <jochen.daum@ca ns.co.nz> wrote:
            [color=blue]
            >Hi Andreas!
            >
            >On Sun, 15 Feb 2004 13:24:30 +0100, Andreas Paasch
            ><Andreas@Paasc h.Net> wrote:
            >[color=green]
            >>
            >>I've finally gotten my nice little system working and it's gone live.
            >>Now, I spent time optimizing my code and adding a little smart functionality
            >>here and there, based on needs and simplicity.
            >>
            >>In this context, I was wondering about something.
            >>
            >>I have a growing include.inc file that holds all my functions in it.
            >>
            >>Thinking speed, I was thinking that it might be a bit faster to split that
            >>include.inc file up into the different functions and then only include_once
            >>those that actually are needed by the different pages.
            >>But without any reference and in-depth knowledge, I don't know if this is a
            >>win situation or loose, in matters of time.
            >>
            >>I'm running Mandrake 9.2 here on a 2.4 kernel but was at the same time
            >>considering to upgrade to 2.6 kernel, once it seems to be solid enough.
            >>According to the NG Mandrake 2.6 kernel still has a very few issues that I'd
            >>like to avoid.
            >>
            >>But considering optimization and time, would it be most practical and faster
            >>to split my functions or keep it as is?[/color]
            >
            >I have measured this for several thousand lines of array declarations,
            >and it is faster than most short loops, that I run. Its not worth
            >optimising, only optimise the slowest code.[/color]

            In my experience, the time taken to open and close several include
            files is much greater than parsing one large file.

            --
            David ( @priz.co.uk )

            Comment

            • Andreas Paasch

              #7
              Re: optimizing code

              David Mackenzie wrote:
              [color=blue]
              > On Mon, 16 Feb 2004 08:39:31 +1300, Jochen Daum
              > <jochen.daum@ca ns.co.nz> wrote:
              >[color=green]
              >>Hi Andreas!
              >>
              >>On Sun, 15 Feb 2004 13:24:30 +0100, Andreas Paasch
              >><Andreas@Paas ch.Net> wrote:
              >>[color=darkred]
              >>>
              >>>I've finally gotten my nice little system working and it's gone live.
              >>>Now, I spent time optimizing my code and adding a little smart
              >>>functionalit y here and there, based on needs and simplicity.
              >>>
              >>>In this context, I was wondering about something.
              >>>
              >>>I have a growing include.inc file that holds all my functions in it.
              >>>
              >>>Thinking speed, I was thinking that it might be a bit faster to split
              >>>that include.inc file up into the different functions and then only
              >>>include_on ce those that actually are needed by the different pages.
              >>>But without any reference and in-depth knowledge, I don't know if this is
              >>>a win situation or loose, in matters of time.
              >>>
              >>>I'm running Mandrake 9.2 here on a 2.4 kernel but was at the same time
              >>>considerin g to upgrade to 2.6 kernel, once it seems to be solid enough.
              >>>According to the NG Mandrake 2.6 kernel still has a very few issues that
              >>>I'd like to avoid.
              >>>
              >>>But considering optimization and time, would it be most practical and
              >>>faster to split my functions or keep it as is?[/color]
              >>
              >>I have measured this for several thousand lines of array declarations,
              >>and it is faster than most short loops, that I run. Its not worth
              >>optimising, only optimise the slowest code.[/color]
              >
              > In my experience, the time taken to open and close several include
              > files is much greater than parsing one large file.
              >[/color]

              That is what came to my mind too, after reading the other two posts.

              /Andreas
              --
              Registeret Linux user #292411

              Comment

              • Perttu Pulkkinen

                #8
                Re: optimizing code


                "Andreas Paasch" <Andreas@Paasch .Net> kirjoitti viestissä
                news:dvJXb.9105 0$jf4.5681483@n ews000.worldonl ine.dk...
                ....[color=blue]
                > I have a growing include.inc file that holds all my functions in it.[/color]
                ....[color=blue]
                > But considering optimization and time, would it be most practical and[/color]
                faster[color=blue]
                > to split my functions or keep it as is?[/color]

                I have not measured any times, I think that is not the problem usually.
                But in my experience, this division is VERY useful:

                - database library (general database things and/or wrapping of certain
                database system (like mysqsl) functions into more general db_functions)
                - standard library (your own often used string and html functions f.ex.)
                - image library (handling of images adn thunmbnails)
                - userlibrary (userside functions of certain application)
                - adminlibrary (admin sideof certain application)

                Advantages:

                * Debugging and developing the code is easier when divided in this way.
                * If first three are wellmade you can use them in almost every application
                without big changes.
                * When user and admin functions are in separate librarys, problems in
                another don't cause the crash of another.

                -perttu, jkl, finland










                Comment

                Working...