473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Processing Bit Strings

I have a script which runs postprocessing on some data and formats the
results into a table. This is compiled into a C project. The perl script
creates an 800x800 matrix of bits (~800 KB). After creating an enormously
long string, it formats it for C source as follows:

# Pad out the end of the bit string to a byte
$bitstr .= '0' x ((8 - (length($bitstr) % 8)) % 8);

# Create an array of bytes
@bytes = ();
while(length($bitstr) > 0)
{
push(@bytes, sprintf('0x%02X', ord(pack('b8', substr($bitstr, 0, 8)))));
$bitstr = substr($bitstr, 8);
}

# Down here I have code to print the array

This takes several minutes to run under perl 5.8 on my Pentium 4 2.53 GHz. I
was wondering if there was a faster way to do this? Several minutes is
usually acceptable, but in a debug cycle I run this script frequently, and
it would make my life much easier if it were faster.

-Matt
Jul 19 '05 #1
0 2263

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: D | last post by:
Hi folks, This may be pretty simple for you guys but it has me stumped. BTW I'm using Java 1.1, I know it's old, don't ask me why, I just have to. I have a long string in excess of 50k that I...
1
by: christof hoeke | last post by:
hi, i wrote a small application which extracts a javadoc similar documentation for xslt stylesheets using python, xslt and pyana. using non-ascii characters was a problem. so i set the...
8
by: OPQ | last post by:
Hi all, I'd happy to have you share some thougts about ultimate optimisations on those 2 topics: (1)- adding one caractere at the end of a string (may be long) (2)- in a dict mapping a key...
3
by: anthony hornby | last post by:
Hi, I am starting my honours degree project and part of it is going to be manipulating ASCII encoded XML files from a legacy database and converting them to Unicode and doing text processing stuff...
23
by: Daniel Rudy | last post by:
Hello, I'm trying to learn how command line arguments are handled in C. The following code segment that I wrote as a test program compiles, but when I try to run it, it core dumps. This is...
6
by: Alexander Muylaert | last post by:
Hi Does anyone know a good starting point about high speed string processing in C#? What I need is a very fast routine for a case insensitive "contains". e == E == é == ë == ... Kind...
4
by: Vinay Agarwal | last post by:
Hello, I would like to maximize efficiency of string processing in my C# application that works with Skype API. Actually, these "strings" are made of "chars" that are all 8-bit values except 0...
3
by: ecov | last post by:
Is there any easy way to read into a dataset a file that was created from a BCP command. The file is in a fixed length format. I would also like to be able to write out a dataset to the same type...
4
by: Alexis Gallagher | last post by:
(I tried to post this yesterday but I think my ISP ate it. Apologies if this is a double-post.) Is it possible to do very fast string processing in python? My bioinformatics application needs to...
6
by: Jeff | last post by:
Hello I want to read and process and rewrite a very large disk based file (>3Gbytes) as quickly as possible. The processing effectively involves finding certain strings and replacing them with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.