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 8846955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:06:48+00:00 2026-06-14T12:06:48+00:00

I have to load a large file into memory and I want to find

  • 0

I have to load a large file into memory and I want to find a substring. Which method is faster?

// application initialization

string instring  = "which is faster find in string or list..."; // large string +- 150MB
List<string> inlist = new List<string>();
foreach (string word in instring) {
    inlist.Add(word);
}

// button click

if (instring.Contains("find")) {
  ...
}

or

if (inlist.Contains("find")) {
  ...
}

I have did some measurement in my case String search was the fastest.

Singel search:
Boyer-Moore search found - elapsed: 00:00:00.0025893
String search found - elapsed: 00:00:00.0026120
List search not found - elapsed: 00:00:00.0026394

Multi search:
Boyer-Moore search found - elapsed: 00:00:00.0027377
Boyer-Moore search found - elapsed: 00:00:00.0028308
Boyer-Moore search found - elapsed: 00:00:00.0029269
Boyer-Moore search found - elapsed: 00:00:00.0030234
Boyer-Moore search found - elapsed: 00:00:00.0031210

String search found - elapsed: 00:00:00.0032474
String search found - elapsed: 00:00:00.0032653
String search found - elapsed: 00:00:00.0032832
String search found - elapsed: 00:00:00.0033015
String search found - elapsed: 00:00:00.0033201


List search not found - elapsed: 00:00:00.0033629
List search not found - elapsed: 00:00:00.0033826
List search not found - elapsed: 00:00:00.0033961
List search not found - elapsed: 00:00:00.0034155
List search not found - elapsed: 00:00:00.0034345
  • 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-06-14T12:06:49+00:00Added an answer on June 14, 2026 at 12:06 pm

    You’re testing radically different things.

    For example, suppose you do indeed look for “find”, and you’ve got a file which is:

    If you're interested in finding the answer, make sure you know the question.
    

    If you split that into a list of strings, one per word, then “find” doesn’t appear – because it’s only part of the word “finding”. Using string.Contains you will find it, however, as it’s a substring.

    You should work out your desired behaviour first, implement it in the simplest, most elegant fashion, then measure performance. If that meets your desired performance, you’re done. If not, you can then try to improve it, measuring at each point and making sure you’ve still got the behaviour you want.

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

Sidebar

Related Questions

I have a large binary file (700 Mb approximately) which I load to TMemoryStream.
I have a very large image (600mb) 30000x30000 and want to load it into
I have a large dataset that load in with a fill method on page
I have to load a kmz file in to the android application that i
I am currently trying to load a slightly large xml file into a dataset.
I have a million points and a large shape file—8GB—which is too big for
I have a large txt file thar I want to parse in my web
I will have a possibly very large JSON file and I want to stream
I have a fairly large .txt file ~9gb and I will like to load
I have a large database and want to implement a feature which would allow

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.