gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: perfomance optimisations


From: Adrian Robert
Subject: Re: perfomance optimisations
Date: Tue, 05 Apr 2005 13:44:36 -0400

I think we should not introduce a lot more IMPs in GSWeb than we now have.
There are other areas that should be addressed.

This is a example of a potential thing that could be faster.
If somebody uses cString it is likely that he also uses cStringLength on the same string. Both does basically the same. Has somebody an idea how to optimize here?

Could you give us an idea of the type/magnitude of performance gains you are wishing for / expecting? Could you post some profiling data for example? I guess I'm a bit surprised that string-handling kinds of things are a problem. Java works very well in the server space and I've never been impressed by the low-level efficiency of its string-handling (or for that matter the overall architecture of how it does things.

Here is, for example, the Java 1.3 implementation of String.getBytes():

    private byte[] getBytes(CharToByteConverter ctb) {
        ctb.reset();
        int estLength = ctb.getMaxBytesPerChar() * count;
        byte[] result = new byte[estLength];
        int length = 0;
        try {
            length += ctb.convertAny(value, offset, (offset + count),
                                     result, 0, estLength);
            length += ctb.flushAny(result, ctb.nextByteIndex(), estLength);
        } catch (CharConversionException e) {
            throw new InternalError("Converter malfunction: " +
                                    ctb.getClass().getName());
        }

        if (length < estLength) {
            // A short format was used:  Trim the byte array.
            byte[] trimResult = new byte[length];
            System.arraycopy(result, 0, trimResult, 0, length);
            return trimResult;
        }
        else {
            return result;
        }
    }

Basically the same as the Base method below, except I'm not sure what that 'append ""' is for. (And this starts out interpreted, then gets just-in-time compiled.)

Anyway, overall Java on the server side is not super-fast compared to PHP or even Perl, but has won wide acceptance because servlets, JSP, and JDBC are simple but effective technologies, and also by being designed for scalability so that more hardware can easily be thrown at a situation with little developer effort. This was accomplished by a well-designed application model where session information is encapsulated and threads are used and reused in lieu of object creation as much as possible.


On Apr 5, 2005, at 1:07 PM, David Wetzel wrote:

- (const char*) cString
{
  NSData        *d;
  NSMutableData *m;

  d = [self dataUsingEncoding: _DefaultStringEncoding
         allowLossyConversion: NO];
  if (d == nil)
    {
      [NSException raise: NSCharacterConversionException
                  format: @"unable to convert to cString"];
    }
  m = [d mutableCopy];
  [m appendBytes: "" length: 1];
  AUTORELEASE(m);
  return (const char*)[m bytes];
}

- (unsigned int) cStringLength
{
  NSData        *d;

  d = [self dataUsingEncoding: _DefaultStringEncoding
         allowLossyConversion: NO];
  return [d length];
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]