Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3991732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:39:05+00:00 2026-05-20T06:39:05+00:00

For evaluating an algorithm I have to count how often the items of a

  • 0

For evaluating an algorithm I have to count how often the items of a byte-array are read/accessed. The byte-array is filled with the contents of a file and my algorithm can skip over many of the bytes in the array (like for example the Boyer–Moore string search algorithm). I have to find out how often an item is actually read. This byte-array is passed around to multiple methods and classes.

My ideas so far:

  1. Increment a counter at each spot where the byte-array is read. This seems error-prone since there are many of these spots. Additionally I would have to remove this code afterwards such that it does not influence the runtime of my algorithm.

  2. Use an ArrayList instead of a byte-array and overwrite its “get” method. Again, there are a lot of methods that would have to be modified and I suspect that there would be a performance loss.

  3. Can I somehow use the Eclipse debug-mode? I see that I can specify a hit-count for watchpoints but it does not seem to be possible to output the hit count?!

  4. Can maybe the Reflection API help me somehow?

  5. Somewhat like 2), but in order to reduce the effort: Can I make a Java method accept an ArrayList where it wants an array such that it transparently calls the “get” method whenever an item is read?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:39:05+00:00Added an answer on May 20, 2026 at 6:39 am

    There might be an out-of-the-box solution but I’d probably just wrap the byte array in a simple class.

    public class ByteArrayWrapper {
      private byte [] bytes;
      private long readCount = 0;
    
      public ByteArrayWrapper( byte [] bytes ) {
        this.bytes = bytes;
      }
    
      public int getSize() { return bytes.length; }
    
      public byte getByte( int index ) { readCount++; return bytes[ index ]; }
    
      public long getReadCount() { return readCount; }
    }
    

    Something along these lines. Of course this does influence the running time but not very much. You could try it and time the difference, if you find it is significant, we’ll have to find another way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have experience with algorithms for evaluating hypergeometric functions? I would be interested
What's the best algorithm for evaluating a mathematical expression? I'd like to be able
Suppose I have a string such as this in a text file: (((var1 AND
I have experienced AlphaBeta algorithm with my own old chess engine and now i
I have a numerical analysis program which for simplicity calculates an algorithm similar to:
I'm currently evaluating the MSF for CMMI process template under TFS for use on
I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript
We are currently evaluating different applications that interface with Visual Studio 2008 (C#) and
I'm evaluating Terracotta to help me scale up an application which is currently RAM-bounded.
I'm evaluating Visual Studio productivity addons for my development team, which includes some folks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.